summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_join.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2001-11-17 14:28:39 +0000
committerdeischen <deischen@FreeBSD.org>2001-11-17 14:28:39 +0000
commitb43c906fd478d13c3c092a2c7ba3198b5557eac6 (patch)
treed9b490926b6ae401659e2052a1b89c5bea09c6d4 /lib/libpthread/thread/thr_join.c
parent82943ba6834c1d4951740dd6dd59a8ff1373b2f8 (diff)
downloadFreeBSD-src-b43c906fd478d13c3c092a2c7ba3198b5557eac6.zip
FreeBSD-src-b43c906fd478d13c3c092a2c7ba3198b5557eac6.tar.gz
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 <rittle@labs.mot.com> MFC after: 1 week
Diffstat (limited to 'lib/libpthread/thread/thr_join.c')
-rw-r--r--lib/libpthread/thread/thr_join.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libpthread/thread/thr_join.c b/lib/libpthread/thread/thr_join.c
index 454c79a..0f5e8fc 100644
--- a/lib/libpthread/thread/thr_join.c
+++ b/lib/libpthread/thread/thr_join.c
@@ -122,18 +122,20 @@ _pthread_join(pthread_t pthread, void **thread_return)
pthread->joiner = curthread;
/* Keep track of which thread we're joining to: */
- curthread->data.thread = pthread;
+ curthread->join_status.thread = pthread;
- /* Schedule the next thread: */
- _thread_kern_sched_state(PS_JOIN, __FILE__, __LINE__);
+ while (curthread->join_status.thread == pthread) {
+ /* Schedule the next thread: */
+ _thread_kern_sched_state(PS_JOIN, __FILE__, __LINE__);
+ }
/*
* The thread return value and error are set by the thread we're
* joining to when it exits or detaches:
*/
- ret = curthread->error;
+ ret = curthread->join_status.error;
if ((ret == 0) && (thread_return != NULL))
- *thread_return = curthread->ret;
+ *thread_return = curthread->join_status.ret;
} else {
/*
* The thread exited (is dead) without being detached, and no
OpenPOWER on IntegriCloud