summaryrefslogtreecommitdiffstats
path: root/lib/libkse
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2004-10-23 23:37:54 +0000
committerdavidxu <davidxu@FreeBSD.org>2004-10-23 23:37:54 +0000
commita4118f925e9103e31b5a18fce34580911b6417ed (patch)
treec774208d2c7bf97dabc3aa08191cf40b985e9ae4 /lib/libkse
parentdf721e35be3c19465326438aaee1cf0445ce76b9 (diff)
downloadFreeBSD-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/libkse')
-rw-r--r--lib/libkse/thread/thr_exit.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/libkse/thread/thr_exit.c b/lib/libkse/thread/thr_exit.c
index ecea47a..456b81d 100644
--- a/lib/libkse/thread/thr_exit.c
+++ b/lib/libkse/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) {
OpenPOWER on IntegriCloud