From 0fb34bb098f1cbdd9d154328cb7f9d45ed8f6256 Mon Sep 17 00:00:00 2001 From: Gerhard Jaeger Date: Thu, 14 Oct 2004 06:51:17 +0000 Subject: [PATCH] Added missing pthread_detach() so the thread resources could be reused again. --- sanei/sanei_thread.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sanei/sanei_thread.c b/sanei/sanei_thread.c index a615eecac..429392c91 100644 --- a/sanei/sanei_thread.c +++ b/sanei/sanei_thread.c @@ -361,7 +361,7 @@ sanei_thread_waitpid( int pid, int *status ) stat = 0; - DBG(2, "sanei_thread_waitpid() - %d\n", (int)pid); + DBG(2, "sanei_thread_waitpid() - %d\n", pid); #ifdef USE_PTHREAD result = pthread_join((pthread_t)pid, (void*)&ls ); @@ -375,6 +375,11 @@ sanei_thread_waitpid( int pid, int *status ) DBG(2, "* result = %d (%p)\n", stat, (void*)status ); result = pid; } + /* call detach in any case to make sure that the thread resources + * will be freed, when the thread has terminated + */ + DBG(2, "* detaching thread(%d)\n", pid ); + pthread_detach((pthread_t)pid); if (status) *status = stat;