From 9e1ad59de6cdb91cebc057205dd22c2d1dc73673 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 1 Feb 2004 18:29:12 +0000 Subject: * cygerrno.h (set_errno): Set global errno whenever setting thread specific version. * debug.cc (__set_errno): Ditto. * exceptions.cc (handle_sigsuspend): Remove spurious sig_dispatch_pending call. (set_signal_mask): When there seem to be pending signals to dispatch, tell signal_dispatch_pending/sig_send not to specifically call any handlers. * sigproc.h (sig_dispatch_pending): Change declaration to void. * sigproc.cc (sig_dispatch_pending): Change definition to void. Take an argument to determine whether to tell sig_send to wait for handler to be called. * sigproc.cc (sig_send): Don't call signal handler when sig == __SIGFLUSHFAST. (wait_sig): Honor __SIGFLUSHFAST. Guard against sigpacket::process nuking si_signo. * sigproc.h (__SIGFLUSHFAST): Define new special signal. (sig_dispatch_pending): Change declaration to void. Take optional boolean argument. * fork.cc (vfork): Add debugging output. --- winsup/cygwin/sigproc.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'winsup/cygwin/sigproc.cc') diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 3be7f8954..327382e8c 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -63,7 +63,7 @@ public: sigpacket *next (); sigpacket *save () const {return curr;} void restore (sigpacket *saved) {curr = saved;} - friend int __stdcall sig_dispatch_pending (); + friend void __stdcall sig_dispatch_pending (bool); }; static pending_signals sigqueue; @@ -431,8 +431,7 @@ proc_subproc (DWORD what, DWORD val) scan_wait: /* Scan the linked list of wait()ing threads. If a wait's parameters - * match this pid, then activate it. - */ + match this pid, then activate it. */ for (w = &waitq_head; w->next != NULL; w = w->next) { if ((potential_match = checkstate (w)) > 0) @@ -567,8 +566,8 @@ sigpending (sigset_t *mask) } /* Force the wait_sig thread to wake up and scan for pending signals */ -int __stdcall -sig_dispatch_pending () +void __stdcall +sig_dispatch_pending (bool fast) { if (exit_state || GetCurrentThreadId () == sigtid || !sigqueue.start.next) { @@ -576,14 +575,13 @@ sig_dispatch_pending () sigproc_printf ("exit_state %d, cur thread id %p, sigtid %p, sigqueue.start.next %p", exit_state, GetCurrentThreadId (), sigtid, sigqueue.start.next); #endif - return 0; + return; } #ifdef DEBUGGING sigproc_printf ("flushing"); #endif - (void) sig_send (myself, __SIGFLUSH); - return call_signal_handler_now (); + (void) sig_send (myself, fast ? __SIGFLUSHFAST : __SIGFLUSH); } /* Message initialization. Called from dll_crt0_1 @@ -800,6 +798,12 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls) ForceCloseHandle (sendsig); } + if (pack.wakeup) + { + ForceCloseHandle (pack.wakeup); + pack.wakeup = NULL; + } + if (rc == WAIT_OBJECT_0) rc = 0; // Successful exit else @@ -811,13 +815,12 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls) rc = -1; } - if (wait_for_completion) + if (wait_for_completion && si.si_signo != __SIGFLUSHFAST) call_signal_handler_now (); out: if (pack.wakeup) ForceCloseHandle (pack.wakeup); - if (si.si_signo != __SIGPENDING) /* nothing */; else if (!rc) @@ -1164,6 +1167,7 @@ wait_sig (VOID *self) *pack.mask |= bit; break; case __SIGFLUSH: + case __SIGFLUSHFAST: sigqueue.reset (); while ((q = sigqueue.next ())) if (q->si.si_signo == __SIGDELETE || q->process () > 0) @@ -1174,6 +1178,7 @@ wait_sig (VOID *self) sig_clear (-pack.si.si_signo); else { + int sig = pack.si.si_signo; int sigres = pack.process (); if (sigres <= 0) { @@ -1183,7 +1188,7 @@ wait_sig (VOID *self) #endif sigqueue.add (pack); // FIXME: Shouldn't add this in !sh condition } - if (pack.si.si_signo == SIGCHLD) + if (sig == SIGCHLD) proc_subproc (PROC_CLEARWAIT, 0); } break; -- cgit v1.2.3