summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/exceptions.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-07-30 03:44:40 +0000
committerChristopher Faylor <me@cgf.cx>2012-07-30 03:44:40 +0000
commitd239805457f0dc790559b2173e943e5aebe90c4e (patch)
treea015664429e36ad8caa921deb24e5202d442bf34 /winsup/cygwin/exceptions.cc
parentc1a11ccfca40ec5d162caf747bca94d9b698c34e (diff)
downloadcygnal-d239805457f0dc790559b2173e943e5aebe90c4e.tar.gz
cygnal-d239805457f0dc790559b2173e943e5aebe90c4e.tar.bz2
cygnal-d239805457f0dc790559b2173e943e5aebe90c4e.zip
* cygwait.cc (cancelable_wait): Add some debugging-only output.
* exceptions.cc (sig_handle_tty_stop): Make sure that incyg is cleared when exiting if we have no parent process. Only wait for signal_arrived. (sigpacket::process): Make continue_now a bool. Delay sending signal_arrived until the end. Make code more defensive to avoid calling signal handler when stopped. Only set signal_arrived when stopped. * sigproc.cc (sig_hold): Rename from sigCONT. Make static. (sig_send): Accommodate sigCONT -> sig_hold rename. (wait_sig): Ditto. * sigproc.h (sigCONT): Delete declaration. * fhandler_console.cc (fhandler_console::write): Use new '%0c' facility to print characters. Change to paranoid to avoid excessive strace output. * fhandler_tty.cc (fhandler_pty_master::accept_input): Make frequent strace printf "paranoid" to help cut down on strace output size. * signal.cc (sigsuspend): Add standard syscall strace output. (sigpause): Ditto. (pause): Ditto. * cygtls.h (_cygtls::reset_signal_arrived): New function.
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r--winsup/cygwin/exceptions.cc66
1 files changed, 33 insertions, 33 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 6c4740059..7db2f00ff 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -735,30 +735,29 @@ sig_handle_tty_stop (int sig)
/* Silently ignore attempts to suspend if there is no accommodating
cygwin parent to deal with this behavior. */
if (!myself->cygstarted)
+ myself->process_state &= ~PID_STOPPED;
+ else
{
- myself->process_state &= ~PID_STOPPED;
- return;
- }
-
- myself->stopsig = sig;
- myself->alert_parent (sig);
- sigproc_printf ("process %d stopped by signal %d", myself->pid, sig);
- HANDLE w4[2];
- w4[0] = sigCONT;
- switch (cancelable_wait (sigCONT, cw_infinite, cw_sig_eintr))
- {
- case WAIT_OBJECT_0:
- case WAIT_SIGNALED:
- myself->stopsig = SIGCONT;
- myself->alert_parent (SIGCONT);
- break;
- default:
- api_fatal ("WaitSingleObject failed, %E");
- break;
+ myself->stopsig = sig;
+ myself->alert_parent (sig);
+ sigproc_printf ("process %d stopped by signal %d", myself->pid, sig);
+ /* FIXME! This does nothing to suspend anything other than the main
+ thread. */
+ DWORD res = cancelable_wait (NULL, cw_infinite, cw_sig_eintr);
+ switch (res)
+ {
+ case WAIT_SIGNALED:
+ myself->stopsig = SIGCONT;
+ myself->alert_parent (SIGCONT);
+ break;
+ default:
+ api_fatal ("WaitSingleObject returned %d", res);
+ break;
+ }
}
_my_tls.incyg = 0;
}
-}
+} /* end extern "C" */
bool
_cygtls::interrupt_now (CONTEXT *cx, int sig, void *handler,
@@ -1122,14 +1121,14 @@ set_signal_mask (sigset_t& setmask, sigset_t newmask)
int __stdcall
sigpacket::process ()
{
- DWORD continue_now;
+ bool continue_now;
struct sigaction dummy = global_sigs[SIGSTOP];
if (si.si_signo != SIGCONT)
continue_now = false;
else
{
- continue_now = myself->process_state & PID_STOPPED;
+ continue_now = ISSTATE (myself, PID_STOPPED);
myself->stopsig = 0;
myself->process_state &= ~PID_STOPPED;
/* Clear pending stop signals */
@@ -1206,9 +1205,7 @@ sigpacket::process ()
if (si.si_signo == SIGCHLD || si.si_signo == SIGIO || si.si_signo == SIGCONT || si.si_signo == SIGWINCH
|| si.si_signo == SIGURG)
{
- sigproc_printf ("default signal %d ignored", si.si_signo);
- if (continue_now)
- SetEvent (tls->signal_arrived);
+ sigproc_printf ("signal %d default is currently ignore", si.si_signo);
goto done;
}
@@ -1224,21 +1221,24 @@ sigpacket::process ()
goto dosig;
stop:
- /* Eat multiple attempts to STOP */
- if (ISSTATE (myself, PID_STOPPED))
- goto done;
handler = (void *) sig_handle_tty_stop;
thissig = dummy;
dosig:
- tls->set_siginfo (this);
- /* Dispatch to the appropriate function. */
- sigproc_printf ("signal %d, signal handler %p", si.si_signo, handler);
- rc = setup_handler (si.si_signo, handler, thissig, tls);
+ if (ISSTATE (myself, PID_STOPPED) && !continue_now)
+ rc = -1; /* No signals delivered if stopped */
+ else
+ {
+ tls->set_siginfo (this);
+ /* Dispatch to the appropriate function. */
+ sigproc_printf ("signal %d, signal handler %p", si.si_signo, handler);
+ rc = setup_handler (si.si_signo, handler, thissig, tls);
+ continue_now = false;
+ }
done:
if (continue_now)
- SetEvent (sigCONT);
+ SetEvent (tls->signal_arrived);
sigproc_printf ("returning %d", rc);
return rc;