aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/signal.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-10-21 04:53:49 +0000
committerChristopher Faylor <me@cgf.cx>2000-10-21 04:53:49 +0000
commitb0de2aa284ccb58f1c8f8e0a598701b51ab5b742 (patch)
treee9de21c89264e0f9987ab88dab845446c1b4bc45 /winsup/cygwin/signal.cc
parente9921bcbaa37b9c3df39ef1d8182d56a9db3cb11 (diff)
downloadnewlib-b0de2aa284ccb58f1c8f8e0a598701b51ab5b742.zip
newlib-b0de2aa284ccb58f1c8f8e0a598701b51ab5b742.tar.gz
newlib-b0de2aa284ccb58f1c8f8e0a598701b51ab5b742.tar.bz2
* fhandler.h (fhandler_console): Remove tcsetpgrp.
* fhandler_console.cc (fhandler_console::tcsetpgrp): Eliminate. * fork.cc (fork_parent): Avoid returning same pid twice in a row regardless of OS. * pinfo.cc (pinfo::init): Rename create argument to flags and treat it as such. * signal.cc (set_sigcatchers): New function. (signal): Use set_sigcatchers to increment or decrement sigcatcher tracker. (sigaction): Ditto. Add debugging output. * spawn.cc (spawn_guts): Always quote first argv[0] argument when it's a COMSPEC shell.
Diffstat (limited to 'winsup/cygwin/signal.cc')
-rw-r--r--winsup/cygwin/signal.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 7ed6e4d..11d0921 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -23,6 +23,23 @@ int sigcatchers; /* FIXME: Not thread safe. */
#define sigtrapped(func) ((func) != SIG_IGN && (func) != SIG_DFL)
+static inline void
+set_sigcatchers (void (*oldsig) (int), void (*cursig) (int))
+{
+#ifdef DEBUGGING
+ int last_sigcatchers = sigcatchers;
+#endif
+ if (!sigtrapped (oldsig) && sigtrapped (cursig))
+ sigcatchers++;
+ else if (sigtrapped (oldsig) && !sigtrapped (cursig))
+ sigcatchers--;
+#ifdef DEBUGGING
+ if (last_sigcatchers != sigcatchers)
+ sigproc_printf ("last %d, old %d, cur %p, cur %p", last_sigcatchers,
+ sigcatchers, oldsig, cursig);
+#endif
+}
+
extern "C" _sig_func_ptr
signal (int sig, _sig_func_ptr func)
{
@@ -39,10 +56,7 @@ signal (int sig, _sig_func_ptr func)
prev = myself->getsig (sig).sa_handler;
myself->getsig (sig).sa_handler = func;
myself->getsig (sig).sa_mask = 0;
- if (!sigtrapped (prev) && sigtrapped (func))
- sigcatchers++;
- else if (sigtrapped (prev) && !sigtrapped (func))
- sigcatchers--;
+ set_sigcatchers (prev, func);
syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
return prev;
@@ -235,6 +249,7 @@ killpg (int pgrp, int sig)
extern "C" int
sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact)
{
+ sigproc_printf ("sig %d, newact %p, oldact %p", sig, newact, oldact);
/* check that sig is in right range */
if (sig < 0 || sig >= NSIG)
{
@@ -257,10 +272,7 @@ sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact)
sig_clear (sig);
if (newact->sa_handler == SIG_DFL && sig == SIGCHLD)
sig_clear (sig);
- if (!sigtrapped (oa.sa_handler) && sigtrapped (newact->sa_handler))
- sigcatchers++;
- else if (sigtrapped (oa.sa_handler) && !sigtrapped (newact->sa_handler))
- sigcatchers--;
+ set_sigcatchers (oa.sa_handler, newact->sa_handler);
}
if (oldact)