proper_name ("David MacKenzie"), \
proper_name ("Stuart Kemp")
-/* 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
-
/* NonStop circa 2011 lacks SA_RESETHAND; see Bug#9076. */
#ifndef SA_RESETHAND
# define SA_RESETHAND 0
/* An info signal was received; arrange for the program to print status. */
static void
-siginfo_handler (int sig)
+siginfo_handler (MAYBE_UNUSED int sig)
{
- if (! SA_NOCLDSTOP)
- signal (sig, siginfo_handler);
info_signal_count++;
}
{
bool catch_siginfo = ! (SIGINFO == SIGUSR1 && getenv ("POSIXLY_CORRECT"));
-#if SA_NOCLDSTOP
-
struct sigaction act;
sigemptyset (&caught_signals);
if (catch_siginfo)
act.sa_flags = SA_NODEFER | SA_RESETHAND;
sigaction (SIGINT, &act, nullptr);
}
-
-#else
-
- if (catch_siginfo)
- {
- signal (SIGINFO, siginfo_handler);
- siginterrupt (SIGINFO, 1);
- }
- if (signal (SIGINT, SIG_IGN) != SIG_IGN)
- {
- signal (SIGINT, interrupt_handler);
- siginterrupt (SIGINT, 1);
- }
-#endif
}
/* Close FD. Return 0 if successful, -1 (setting errno) otherwise.
# include <langinfo.h>
#endif
-/* 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
-
/* NonStop circa 2011 lacks both SA_RESTART and siginterrupt, so don't
restart syscalls after a signal handler fires. This may cause
colors to get messed up on the screen if 'ls' is interrupted, but
static void
sighandler (int sig)
{
- if (! SA_NOCLDSTOP)
- signal (sig, SIG_IGN);
if (! interrupt_signal)
interrupt_signal = sig;
}
/* A SIGTSTP was received; arrange for the program to suspend itself. */
static void
-stophandler (int sig)
+stophandler (MAYBE_UNUSED int sig)
{
- if (! SA_NOCLDSTOP)
- signal (sig, stophandler);
if (! interrupt_signal)
stop_signal_count++;
}
enum { nsigs = countof (term_sig), nstop = countof (stop_sig) };
-#if ! SA_NOCLDSTOP
- static bool caught_sig[nsigs + nstop];
-#endif
-
if (init)
{
-#if SA_NOCLDSTOP
struct sigaction act;
sigemptyset (&caught_signals);
sigaction (sig, &act, nullptr);
}
}
-#else
- for (int j = 0; j < nsigs + nstop; j++)
- {
- int sig = j < nsigs ? term_sig[j]: stop_sig[j - nsigs];
- caught_sig[j] = (signal (sig, SIG_IGN) != SIG_IGN);
- if (caught_sig[j])
- {
- signal (sig, j < nsigs ? sighandler : stophandler);
- siginterrupt (sig[j], 0);
- }
- }
-#endif
}
else /* restore. */
{
for (int j = 0; j < nsigs + nstop; j++)
{
int sig = j < nsigs ? term_sig[j]: stop_sig[j - nsigs];
-#if SA_NOCLDSTOP
if (sigismember (&caught_signals, sig))
-#else
- if (caught_sig[j])
-#endif
signal (sig, SIG_DFL);
}
}
# include <langinfo.h>
#endif
-/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
- present. */
-#ifndef SA_NOCLDSTOP
-# define SA_NOCLDSTOP 0
-/* No sigprocmask. Always 'return' zero. */
-# define sigprocmask(How, Set, Oset) (0)
-# define sigset_t int
-# if ! HAVE_SIGINTERRUPT
-# define siginterrupt(sig, flag) /* empty */
-# endif
-#endif
-
#if !defined OPEN_MAX && defined NR_OPEN
# define OPEN_MAX NR_OPEN
#endif
static void
sighandler (int sig)
{
- if (! SA_NOCLDSTOP)
- signal (sig, SIG_IGN);
-
cleanup ();
signal (sig, SIG_DFL);
{
enum { nsigs = countof (term_sig) };
-#if SA_NOCLDSTOP
struct sigaction act;
sigemptyset (&caught_signals);
for (size_t i = 0; i < nsigs; i++)
if (sigismember (&caught_signals, term_sig[i]))
sigaction (term_sig[i], &act, nullptr);
-#else
- for (size_t i = 0; i < nsigs; i++)
- if (signal (term_sig[i], SIG_IGN) != SIG_IGN)
- {
- signal (term_sig[i], sighandler);
- siginterrupt (term_sig[i], 1);
- }
-#endif
}
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */