summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/exceptions.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-08-25 03:12:48 +0000
committerChristopher Faylor <me@cgf.cx>2005-08-25 03:12:48 +0000
commitb9ebff640a76197a91b086a9aff4a6db53cc9d4b (patch)
tree26e625c9d0e4b4ac28456ccf971593d1f4ece985 /winsup/cygwin/exceptions.cc
parent5092e4a714467dc7ee86a8bc33168ed8d66ce5cb (diff)
downloadcygnal-b9ebff640a76197a91b086a9aff4a6db53cc9d4b.tar.gz
cygnal-b9ebff640a76197a91b086a9aff4a6db53cc9d4b.tar.bz2
cygnal-b9ebff640a76197a91b086a9aff4a6db53cc9d4b.zip
* exceptions.cc (handle_sigsuspend): Just sleep forever if called from non-main
thread. (sigpacket:process): Simplify logic which determines when and how a signal is masked. Don't trigger sigwait if there is a signal handler. * sigproc.cc (wait_sig): Update comment. Try to process a signal which is in the queue if it isn't queued for the target thread (this is still not right).
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r--winsup/cygwin/exceptions.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 9ae77f8d2..e75ee610a 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -590,6 +590,8 @@ handle_exceptions (EXCEPTION_RECORD *e0, void *frame, CONTEXT *in0, void *)
int __stdcall
handle_sigsuspend (sigset_t tempmask)
{
+ if (&_my_tls != _main_tls)
+ Sleep (INFINITE);
sigset_t oldmask = myself->getsigmask (); // Remember for restoration
set_signal_mask (tempmask, myself->getsigmask ());
@@ -911,6 +913,7 @@ extern "C" void __stdcall
set_process_mask (sigset_t newmask)
{
set_signal_mask (newmask, myself->getsigmask ());
+sigproc_printf ("mask now %p\n", myself->getsigmask ());
}
extern "C" int
@@ -1014,9 +1017,12 @@ sigpacket::process ()
myself->rusage_self.ru_nsignals++;
+ bool masked;
+ void *handler = (void *) thissig.sa_handler;
+
if (si.si_signo == SIGKILL)
goto exit_sig;
- if ( si.si_signo == SIGSTOP)
+ if (si.si_signo == SIGSTOP)
{
sig_clear (SIGCONT);
if (!tls)
@@ -1024,35 +1030,34 @@ sigpacket::process ()
goto stop;
}
- bool masked;
- bool special_case;
bool insigwait_mask;
- insigwait_mask = masked = false;
- if (special_case = (/*VFORKPID || */ISSTATE (myself, PID_STOPPED)))
- /* nothing to do */;
- else if (tls && sigismember (&tls->sigwait_mask, si.si_signo))
- insigwait_mask = true;
- else if (!tls && (tls = _cygtls::find_tls (si.si_signo)))
- insigwait_mask = true;
- else if (!(masked = sigismember (mask, si.si_signo)) && tls)
- masked = sigismember (&tls->sigmask, si.si_signo);
+ if ((masked = ISSTATE (myself, PID_STOPPED)))
+ insigwait_mask = false;
+ else if (!tls)
+ insigwait_mask = !handler && (tls = _cygtls::find_tls (si.si_signo));
+ else
+ insigwait_mask = sigismember (&tls->sigwait_mask, si.si_signo);
if (insigwait_mask)
goto thread_specific;
+ if (masked)
+ /* nothing to do */;
+ else if (sigismember (mask, si.si_signo))
+ masked = true;
+ else if (tls)
+ masked = sigismember (&tls->sigmask, si.si_signo);
+
if (!tls)
tls = _main_tls;
- if (special_case || masked)
+ if (masked)
{
sigproc_printf ("signal %d blocked", si.si_signo);
rc = -1;
goto done;
}
- void *handler;
- handler = (void *) thissig.sa_handler;
-
/* Clear pending SIGCONT on stop signals */
if (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU)
sig_clear (SIGCONT);