summaryrefslogtreecommitdiff
path: root/pthread/pt-join.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthread/pt-join.c')
-rw-r--r--pthread/pt-join.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/pthread/pt-join.c b/pthread/pt-join.c
index 06e9f1f7..153058b5 100644
--- a/pthread/pt-join.c
+++ b/pthread/pt-join.c
@@ -54,12 +54,20 @@ pthread_join (pthread_t thread, void **status)
if (status)
*status = pthread->status;
- /* Make sure nobody can reference it anymore, and mark it as
- terminated. */
+ /* 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;