summaryrefslogtreecommitdiff
path: root/libpthread/pthread/pt-detach.c
diff options
context:
space:
mode:
authorneal <neal>2008-08-16 11:28:22 +0000
committerneal <neal>2008-08-16 11:28:22 +0000
commit66da40a602fe373aab0bfdf22e711cb74dfc91f4 (patch)
tree1910d87f3fca97500896470d80ee649a4c4b3347 /libpthread/pthread/pt-detach.c
parent54e51f1330ed2f31fd5b7a7260478880c54d33b7 (diff)
2008-08-16 Neal H. Walfield <neal@gnu.org>
* pthread/pt-detach.c (pthread_detach): If destroying the thread, call __pthread_thread_halt before deallocating the stack. In this case, also call __pthread_thread_dealloc on the tcb.
Diffstat (limited to 'libpthread/pthread/pt-detach.c')
-rw-r--r--libpthread/pthread/pt-detach.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libpthread/pthread/pt-detach.c b/libpthread/pthread/pt-detach.c
index 42a8408..1e42c45 100644
--- a/libpthread/pthread/pt-detach.c
+++ b/libpthread/pthread/pt-detach.c
@@ -58,10 +58,20 @@ pthread_detach (pthread_t thread)
__pthread_mutex_unlock (&pthread->state_lock);
+ /* Make sure the thread is not running before we remove its
+ stack. (The only possibility is that it is in a call to
+ __pthread_thread_halt itself, but that is enough to cause a
+ sigsegv.) */
+ __pthread_thread_halt (pthread);
+
+ /* Destroy the stack, the kernel resources and the control
+ block. */
assert (pthread->stack);
__pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
pthread->stack = 0;
+ __pthread_thread_dealloc (pthread);
+
__pthread_dealloc (pthread);
break;