From a4118f925e9103e31b5a18fce34580911b6417ed Mon Sep 17 00:00:00 2001 From: davidxu Date: Sat, 23 Oct 2004 23:37:54 +0000 Subject: Check unhandled signals before thread marks itself as DEAD, this reduces chances of signal losting problem found by Peter Holm --- lib/libkse/thread/thr_exit.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/libkse/thread/thr_exit.c') 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) { -- cgit v1.1