From a709a0a2bd08c944968433ad984973b32cedc0ae Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 3 Sep 2025 16:49:31 -0700 Subject: [PATCH] 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. --- configure.ac | 4 ---- src/sdiff.c | 16 +++++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 19bc5ef..ff79236 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/sdiff.c b/src/sdiff.c index a21b081..278b5a2 100644 --- a/src/sdiff.c +++ b/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]);