mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-26 15:03:22 +00:00
diff: simplify sigaction configuration
* configure.ac: Remove checks for sigaction, sigprocmask, sigblock. The sigprocmask and sigblock checks were not being used anyway. * src/sdiff.c: Use (defined SA_NOCLDSTOP) instead of HAVE_SIGACTION. This is what other modules do.
This commit is contained in:
parent
b4524ba9a6
commit
a709a0a2bd
@ -87,10 +87,6 @@ AC_HEADER_DIRENT
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_TYPE_PID_T
|
||||
|
||||
AC_CHECK_FUNCS_ONCE([sigaction sigprocmask])
|
||||
if test $ac_cv_func_sigprocmask = no; then
|
||||
AC_CHECK_FUNCS([sigblock])
|
||||
fi
|
||||
AC_FUNC_FORK
|
||||
|
||||
dnl O_PATH exists since Linux 2.6.39, but is supported with fstat() only since
|
||||
|
||||
16
src/sdiff.c
16
src/sdiff.c
@ -100,7 +100,9 @@ enum
|
||||
typedef void (*sighandler) (int);
|
||||
static void signal_handler (int, sighandler);
|
||||
|
||||
#if HAVE_SIGACTION
|
||||
/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
|
||||
present. */
|
||||
#ifdef SA_NOCLDSTOP
|
||||
/* Prefer 'sigaction' if available, since 'signal' can lose signals. */
|
||||
static struct sigaction initial_action[NUM_SIGS];
|
||||
static sighandler
|
||||
@ -714,21 +716,21 @@ static bool sigs_trapped;
|
||||
static void
|
||||
catchsig (int s)
|
||||
{
|
||||
#if ! HAVE_SIGACTION
|
||||
#ifndef SA_NOCLDSTOP
|
||||
signal (s, SIG_IGN);
|
||||
#endif
|
||||
if (! (s == SIGINT && ignore_SIGINT))
|
||||
signal_received = s;
|
||||
}
|
||||
|
||||
#if HAVE_SIGACTION
|
||||
#ifdef SA_NOCLDSTOP
|
||||
static struct sigaction catchaction;
|
||||
#endif
|
||||
|
||||
static void
|
||||
signal_handler (int sig, sighandler handler)
|
||||
{
|
||||
#if HAVE_SIGACTION
|
||||
#ifdef SA_NOCLDSTOP
|
||||
catchaction.sa_handler = handler;
|
||||
sigaction (sig, &catchaction, 0);
|
||||
#else
|
||||
@ -739,7 +741,7 @@ signal_handler (int sig, sighandler handler)
|
||||
static void
|
||||
trapsigs (void)
|
||||
{
|
||||
#if HAVE_SIGACTION
|
||||
#ifdef SA_NOCLDSTOP
|
||||
catchaction.sa_flags = SA_RESTART;
|
||||
sigemptyset (&catchaction.sa_mask);
|
||||
for (int i = 0; i < NUM_SIGS; i++)
|
||||
@ -748,7 +750,7 @@ trapsigs (void)
|
||||
|
||||
for (int i = 0; i < NUM_SIGS; i++)
|
||||
{
|
||||
#if HAVE_SIGACTION
|
||||
#ifdef SA_NOCLDSTOP
|
||||
sigaction (sigs[i], nullptr, &initial_action[i]);
|
||||
#else
|
||||
initial_action[i] = signal (sigs[i], SIG_IGN);
|
||||
@ -773,7 +775,7 @@ untrapsig (int s)
|
||||
for (int i = 0; i < NUM_SIGS; i++)
|
||||
if ((! s || sigs[i] == s) && initial_handler (i) != SIG_IGN)
|
||||
{
|
||||
#if HAVE_SIGACTION
|
||||
#ifdef SA_NOCLDSTOP
|
||||
sigaction (sigs[i], &initial_action[i], nullptr);
|
||||
#else
|
||||
signal (sigs[i], initial_action[i]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user