From: Collin Funk Date: Wed, 3 Dec 2025 03:16:23 +0000 (-0800) Subject: timeout: print the signal number 0 instead of EXIT X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c00a0941881e36a71c999f50a51ac6d36b31558f;p=thirdparty%2Fcoreutils.git timeout: print the signal number 0 instead of EXIT POSIX.1-2024 added sig2str but leaves the behavior when called with signal 0 unspecified. FreeBSD 15.0 does not return the signal name EXIT like Gnulib's version causing a test failure. This fixes that and changes the behavior to print 0 instead of EXIT, to avoid confusion when the program does not exit. * NEWS: Mention the change. * src/timeout.c (cleanup): Use snprintf instead of sig2str if the signal is 0. * tests/timeout/timeout.sh: Updated the expected output. --- diff --git a/NEWS b/NEWS index 445e8fb4a0..127d70ae08 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,8 @@ GNU coreutils NEWS -*- outline -*- timeout(1) in a shell backgrounded job, will not terminate upon receiving SIGINT or SIGQUIT, as these are ignored by default in shell background jobs. + 'timeout -v -s 0' now prints the signal number 0 instead of EXIT. + ** Improvements csplit, ls, and sort, now handle a more complete set of terminating signals. diff --git a/src/timeout.c b/src/timeout.c index 3303b57786..017078286a 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -232,7 +232,7 @@ cleanup (int sig) if (verbose) { char signame[MAX (SIG2STR_MAX, INT_BUFSIZE_BOUND (int))]; - if (sig2str (sig, signame) != 0) + if (sig == 0 || sig2str (sig, signame) != 0) snprintf (signame, sizeof signame, "%d", sig); error (0, 0, _("sending signal %s to command %s"), signame, quote (command)); diff --git a/tests/timeout/timeout.sh b/tests/timeout/timeout.sh index c7d8a2906f..3aaed93a72 100755 --- a/tests/timeout/timeout.sh +++ b/tests/timeout/timeout.sh @@ -62,7 +62,7 @@ test "$out" = "" && test $status = 124 || fail=1 # Verify --verbose output cat > exp <<\EOF -timeout: sending signal EXIT to command 'sleep' +timeout: sending signal 0 to command 'sleep' timeout: sending signal KILL to command 'sleep' EOF for opt in -v --verbose; do