* thread.cc (MTinterface::fixup_after_fork): Fix thread list after fork.

(pthread::threads): Instantiate.
(pthread::pthread): Initialize running and suspendend.
Initialize next with NULL.
Add thread to thread list if it is not the null_pthread.
(pthread::~pthread): Remove thread from thread list if it is not the null_pthread.
(pthread::postcreate): Set running flag.
(pthread::exit): Reset running flag.
(pthread::cancel): Try to cancel thread only if still running.
(pthread::_fixup_after_fork): Implement.
(pthread::detach): Check if thread is still running before detach.
* thread.h (pthread::running): New member.
(pthread::next): Ditto.
(pthread::fixup_after_fork): New static method.
(pthread::threads): New static method.
(pthread::_fixup_after_fork): New method.
This commit is contained in:
Thomas Pfaff
2003-06-24 20:14:01 +00:00
parent b8f7ea5ccb
commit e1e196a225
3 changed files with 72 additions and 10 deletions

View File

@@ -385,11 +385,11 @@ public:
void *(*function) (void *);
void *arg;
void *return_ptr;
bool running;
bool suspended;
int cancelstate, canceltype;
HANDLE cancel_event;
pthread_t joiner;
// int joinable;
/* signal handling */
struct sigaction *sigs;
@@ -442,11 +442,21 @@ public:
return t1 == t2;
}
/* List support calls */
class pthread *next;
static void fixup_after_fork ()
{
threads.for_each (&pthread::_fixup_after_fork);
}
private:
static List<pthread> threads;
DWORD thread_id;
__pthread_cleanup_handler *cleanup_stack;
pthread_mutex mutex;
void _fixup_after_fork ();
void pop_all_cleanup_handlers (void);
void precreate (pthread_attr *);
void postcreate ();