summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-04-09 04:56:10 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-04-09 04:56:10 +0000
commitbc7c9f0ebcaefd104b0308ea1486e33d30b79519 (patch)
treed938ac37dff9fe580e2f2a67854098f2f5b1bf23 /src
parent4f0b9dbd173e09de31389156a4506fe77687bf5e (diff)
downloadcoreutils-bc7c9f0ebcaefd104b0308ea1486e33d30b79519.tar.xz
(SA_NOCLDSTOP): Define to 0 if not defined.
All uses changed. (siginterrupt) [! HAVE_SIGINTERRUPT]: New macro. (main) [! SA_NOCLDSTOP]: Use it.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/ls.c b/src/ls.c
index 6739a4296..832507947 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -60,9 +60,15 @@
#include <getopt.h>
#include <signal.h>
+/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
+ present. */
#ifndef SA_NOCLDSTOP
+# define SA_NOCLDSTOP 0
# define sigprocmask(How, Set, Oset) /* empty */
# define sigset_t int
+# if ! HAVE_SIGINTERRUPT
+# define siginterrupt(sig, flag) /* empty */
+# endif
#endif
/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */
@@ -1026,10 +1032,8 @@ restore_default_color (void)
static void
sighandler (int sig)
{
-#ifndef SA_NOCLDSTOP
- signal (sig, SIG_IGN);
-#endif
-
+ if (! SA_NOCLDSTOP)
+ signal (sig, SIG_IGN);
if (! interrupt_signal)
interrupt_signal = sig;
}
@@ -1039,10 +1043,8 @@ sighandler (int sig)
static void
stophandler (int sig)
{
-#ifndef SA_NOCLDSTOP
- signal (sig, stophandler);
-#endif
-
+ if (! SA_NOCLDSTOP)
+ signal (sig, stophandler);
if (! interrupt_signal)
stop_signal_count++;
}
@@ -1104,7 +1106,7 @@ main (int argc, char **argv)
SIGQUIT, SIGTERM, SIGTSTP };
enum { nsigs = sizeof sig / sizeof sig[0] };
-#ifndef SA_NOCLDSTOP
+#if ! SA_NOCLDSTOP
bool caught_sig[nsigs];
#endif
@@ -1146,7 +1148,7 @@ main (int argc, char **argv)
if (0 <= tcgetpgrp (STDOUT_FILENO))
{
int j;
-#ifdef SA_NOCLDSTOP
+#if SA_NOCLDSTOP
struct sigaction act;
sigemptyset (&caught_signals);
@@ -1171,7 +1173,10 @@ main (int argc, char **argv)
{
caught_sig[j] = (signal (sig[j], SIG_IGN) != SIG_IGN);
if (caught_sig[j])
- signal (sig[j], sig[j] == SIGTSTP ? stophandler : sighandler);
+ {
+ signal (sig[j], sig[j] == SIGTSTP ? stophandler : sighandler);
+ siginterrupt (sig[j], 0);
+ }
}
#endif
}
@@ -1293,7 +1298,7 @@ main (int argc, char **argv)
fflush (stdout);
/* Restore the default signal handling. */
-#ifdef SA_NOCLDSTOP
+#if SA_NOCLDSTOP
for (j = 0; j < nsigs; j++)
if (sigismember (&caught_signals, sig[j]))
signal (sig[j], SIG_DFL);