diff options
author | davidxu <davidxu@FreeBSD.org> | 2004-10-23 23:37:54 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2004-10-23 23:37:54 +0000 |
commit | a4118f925e9103e31b5a18fce34580911b6417ed (patch) | |
tree | c774208d2c7bf97dabc3aa08191cf40b985e9ae4 /lib/libpthread/thread | |
parent | df721e35be3c19465326438aaee1cf0445ce76b9 (diff) | |
download | FreeBSD-src-a4118f925e9103e31b5a18fce34580911b6417ed.zip FreeBSD-src-a4118f925e9103e31b5a18fce34580911b6417ed.tar.gz |
Check unhandled signals before thread marks itself as DEAD,
this reduces chances of signal losting problem found by
Peter Holm <peter@holm.cc>
Diffstat (limited to 'lib/libpthread/thread')
-rw-r--r-- | lib/libpthread/thread/thr_exit.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/libpthread/thread/thr_exit.c b/lib/libpthread/thread/thr_exit.c index ecea47a..456b81d 100644 --- a/lib/libpthread/thread/thr_exit.c +++ b/lib/libpthread/thread/thr_exit.c @@ -105,7 +105,20 @@ _pthread_exit(void *status) THR_SCHED_LOCK(curthread, curthread); curthread->flags |= THR_FLAGS_EXITING; THR_SCHED_UNLOCK(curthread, curthread); - + + /* + * To avoid signal-lost problem, if signals had already been + * delivered to us, handle it. we have already set EXITING flag + * so no new signals should be delivered to us. + * XXX this is not enough if signal was delivered just before + * thread called sigprocmask and masked it! in this case, we + * might have to re-post the signal by kill() if the signal + * is targeting process (not for a specified thread). + * Kernel has same signal-lost problem, a signal may be delivered + * to a thread which is on the way to call sigprocmask or thr_exit()! + */ + if (curthread->check_pending) + _thr_sig_check_pending(curthread); /* Save the return value: */ curthread->ret = status; while (curthread->cleanup != NULL) { |