diff options
Diffstat (limited to 'src/threadengines/threadengine_pthread.cpp')
-rw-r--r-- | src/threadengines/threadengine_pthread.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp index da120bfab..8bdcd6d96 100644 --- a/src/threadengines/threadengine_pthread.cpp +++ b/src/threadengines/threadengine_pthread.cpp @@ -36,6 +36,7 @@ void PThreadEngine::Create(Thread* thread_to_init) { pthread_attr_t attribs; pthread_attr_init(&attribs); + pthread_attr_setdetachstate(&attribs, PTHREAD_CREATE_JOINABLE); pthread_t* MyPThread = new pthread_t; if (pthread_create(MyPThread, &attribs, PThreadEngine::Entry, (void*)this) != 0) @@ -44,6 +45,8 @@ void PThreadEngine::Create(Thread* thread_to_init) throw CoreException("Unable to create new PThreadEngine: " + std::string(strerror(errno))); } + pthread_attr_destroy(&attribs); + NewThread = thread_to_init; NewThread->Creator = this; NewThread->Extend("pthread", MyPThread); @@ -81,6 +84,10 @@ void PThreadEngine::FreeThread(Thread* thread) pthread_t* pthread = NULL; if (thread->GetExt("pthread", pthread)) { + thread->SetExitFlag(); + int rc; + void* status; + rc = pthread_join(*pthread, &status); delete pthread; } } |