diff options
author | Christopher Faylor <me@cgf.cx> | 2004-03-07 04:57:47 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2004-03-07 04:57:47 +0000 |
commit | 3a1ccfc8c7e618eec1eb280a213282f1134eb2fb (patch) | |
tree | f394d22b8233c39ccb86f98b168cff560f9a7173 /winsup/cygwin/exceptions.cc | |
parent | 2942097ac20fab2d8237e9f7004cd2153b6ac0af (diff) | |
download | cygnal-3a1ccfc8c7e618eec1eb280a213282f1134eb2fb.tar.gz cygnal-3a1ccfc8c7e618eec1eb280a213282f1134eb2fb.tar.bz2 cygnal-3a1ccfc8c7e618eec1eb280a213282f1134eb2fb.zip |
* fork.cc (fork_parent): Save parent pid in a temporary variable since child
could conceivably exit before function returns, rendering the child's shared
memory area invalid.
* cygtls.h (_cygtls::incyg): Declare new field.
(_cygtls::in_exception): Define new function.
* exceptions.cc (setup_handler): Remove locked flag. Use 'incyg' flag and
in_exception function to determine when we're in a cygwin function.
(_cygtls::call_signal_handler): Decrement incyg flag prior to calling a
handler. Increment it on return.
* gendef (_sigfe): Increment incyg flag. Use testl for zero testing rather
than orl, for consistency.
(_sigbe): Decrement incyg flag. Use testl for zero testing rather than orl,
for consistency.
(_cygtls::pop): Use testl for zero testing rather than orl, for consistency.
(stabilize_sig_stack): Ditto.
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r-- | winsup/cygwin/exceptions.cc | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 45d840aee..086ced32b 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -742,7 +742,6 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls) { CONTEXT cx; bool interrupted = false; - bool locked = false; if (tls->sig) { @@ -754,18 +753,17 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls) for (int i = 0; i < CALL_HANDLER_RETRY; i++) { tls->lock (); - locked = true; - if (tls->stackptr > tls->stack) + if (tls->incyg || tls->in_exception ()) { tls->reset_exception (); tls->interrupt_setup (sig, handler, siga); sigproc_printf ("interrupted known cygwin routine"); interrupted = true; + tls->unlock (); break; } tls->unlock (); - locked = false; DWORD res; HANDLE hth = (HANDLE) *tls; @@ -776,7 +774,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls) since we don't want to stall the signal handler. FIXME: Will this result in noticeable delays? If the thread is already suspended (which can occur when a program has called - SuspendThread on itself then just queue the signal. */ + SuspendThread on itself) then just queue the signal. */ #ifndef DEBUGGING sigproc_printf ("suspending mainthread"); @@ -788,7 +786,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls) #endif res = SuspendThread (hth); /* Just set pending if thread is already suspended */ - if (res || tls->stackptr > tls->stack) + if (res || tls->incyg) { (void) ResumeThread (hth); break; @@ -811,8 +809,6 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls) } out: - if (locked) - tls->unlock (); if (interrupted && tls->event) { HANDLE h = tls->event; @@ -1185,8 +1181,10 @@ _cygtls::call_signal_handler () sigset_t this_oldmask = oldmask; int this_errno = saved_errno; set_process_mask (newmask); + incyg--; sig = 0; sigfunc (thissig); + incyg++; set_process_mask (this_oldmask); if (this_errno >= 0) set_errno (this_errno); |