From b43c906fd478d13c3c092a2c7ba3198b5557eac6 Mon Sep 17 00:00:00 2001 From: deischen Date: Sat, 17 Nov 2001 14:28:39 +0000 Subject: Fix pthread_join so that it works if the target thread exits while the joining thread is in a signal handler. Reported by: Loren James Rittle MFC after: 1 week --- lib/libpthread/thread/thr_sig.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/libpthread/thread/thr_sig.c') diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c index 9ca197e..a05f914 100644 --- a/lib/libpthread/thread/thr_sig.c +++ b/lib/libpthread/thread/thr_sig.c @@ -671,7 +671,6 @@ thread_sig_add(pthread_t pthread, int sig, int has_args) * signal handler to run: */ case PS_COND_WAIT: - case PS_JOIN: case PS_MUTEX_WAIT: /* * Remove the thread from the wait queue. It will @@ -681,6 +680,17 @@ thread_sig_add(pthread_t pthread, int sig, int has_args) PTHREAD_WAITQ_REMOVE(pthread); break; + case PS_JOIN: + /* + * Remove the thread from the wait queue. It will + * be added back to the wait queue once all signal + * handlers have been invoked. + */ + PTHREAD_WAITQ_REMOVE(pthread); + /* Make the thread runnable: */ + PTHREAD_SET_STATE(pthread, PS_RUNNING); + break; + /* * States which are interruptible but may need to be removed * from queues before any signal handler is called. -- cgit v1.1