logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: aee69b2cb95047c6d1cb4c75440e6cfb151c1718
parent 973ec0b44f5079cfefae84abb25f5b4b42bf693e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 30 Nov 2025 07:46:31 +0100

cmd/time: define a no-op handler for SIGCHLD

Diffstat:

Mcmd/time.c21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/cmd/time.c b/cmd/time.c @@ -28,6 +28,17 @@ enum cmd_time_mode CMD_TIME_VERBOSE = 1, }; +/* + * no-op signal handler so sigprocmask/sigwait works on BSDs where signals + * that are ignored/discarded by default aren't blocked unless they + * have a handler + */ +static void +sig_noop(int sig) +{ + return; +} + static void usage(void) { @@ -89,6 +100,16 @@ main(int argc, char *argv[]) sigset_t sigset; if(sigfillset(&sigset) != 0) return 1; + struct sigaction sa = { + .sa_handler = &sig_noop, + .sa_flags = 0, + }; + if(sigaction(SIGCHLD, &sa, NULL) != 0) + { + fprintf(stderr, "time: error: Failed setting SIGCHLD handler: %s\n", strerror(errno)); + return 1; + } + if(sigprocmask(SIG_BLOCK, &sigset, NULL) != 0) { fprintf(stderr, "time: error: Failed setting process' signal mask: %s\n", strerror(errno));