]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
timeout: print the signal number 0 instead of EXIT
authorCollin Funk <collin.funk1@gmail.com>
Wed, 3 Dec 2025 03:16:23 +0000 (19:16 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Wed, 3 Dec 2025 03:16:23 +0000 (19:16 -0800)
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.

NEWS
src/timeout.c
tests/timeout/timeout.sh

diff --git a/NEWS b/NEWS
index 445e8fb4a0edfef28ff7bc6c59ccf09494ab718b..127d70ae08a4a6f2b7c7a4fc5dd9821b5f46d277 100644 (file)
--- 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.
index 3303b57786b15bb6989a0d81385538e19c034c4f..017078286a960462b04fcc21128ef1f3b48dfeda 100644 (file)
@@ -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));
index c7d8a2906f9fb1f49f1035d866e7096cf3be432d..3aaed93a725158a804709d59f23610f1a8d4cc45 100755 (executable)
@@ -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