]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
kill: with -l,-t list signal 0
authorPádraig Brady <P@draigBrady.com>
Sat, 21 Dec 2024 12:54:59 +0000 (12:54 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 23 Dec 2024 11:49:10 +0000 (11:49 +0000)
The 0 (EXIT) signal is valid as input
(and useful to determine existence of a pid),
so list it along with other signals.

* doc/coreutils.texi (signal specifications): Document 0, "EXIT".
* src/kill.c (list_signals): Start loops at 0, not 1.
* tests/misc/kill.sh: Add a test case.
* NEWS: Mention the change in behavior.

NEWS
doc/coreutils.texi
src/kill.c
tests/misc/kill.sh

diff --git a/NEWS b/NEWS
index 9c6f2fb0dc487a5e386cb64ff55e1c3d6d99ab6b..f76393506d90cd1535b6b00838e890aee711d43f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,8 @@ GNU coreutils NEWS                                    -*- outline -*-
   install -C now dereferences symlink sources when comparing,
   rather than always treating as different and performing the copy.
 
+  kill -l and -t now list signal 0, as it's a valid signal to send.
+
   ls's -f option now simply acts like -aU, instead of also ignoring
   some earlier options.  For example 'ls -fl' and 'ls -lf' are now
   equivalent because -f no longer ignores an earlier -l.  The new
index 39a9ac05fa718c9e2d7c792019f67b254727516f..11a51706b53364776dd9489fa481db17edb10f7e 100644 (file)
@@ -1083,8 +1083,16 @@ apparent file sizes, whereas the @option{--block-size} option does.
 A @var{signal} may be a signal name like @samp{HUP}, or a signal
 number like @samp{1}, or an exit status of a process terminated by the
 signal.  A signal name can be given in canonical form or prefixed by
-@samp{SIG}@.  The case of the letters is ignored.  The following signal names
-and numbers are supported on all POSIX compliant systems:
+@samp{SIG}@.  The case of the letters is ignored.
+
+@noindent
+The signal @samp{0} pseudo signal is synonymous with the name @samp{EXIT}
+with the GNU @command{kill} command, and @command{bash} at least,
+as @code{trap foo 0} and @code{trap foo EXIT} are equivalent.
+
+@noindent
+The following signal names and numbers are supported
+on all POSIX compliant systems:
 
 @table @samp
 @item HUP
index 8b9a2650fbf55715828e966dafaf383e3f6fc558..314855653ecb88ef8ccbad7ff98feabb58888d63 100644 (file)
@@ -120,7 +120,7 @@ list_signals (bool table, char *const *argv)
         num_width++;
 
       /* Compute the maximum width of a signal name.  */
-      for (signum = 1; signum <= SIGNUM_BOUND; signum++)
+      for (signum = 0; signum <= SIGNUM_BOUND; signum++)
         if (sig2str (signum, signame) == 0)
           {
             idx_t len = strlen (signame);
@@ -142,7 +142,7 @@ list_signals (bool table, char *const *argv)
               }
           }
       else
-        for (signum = 1; signum <= SIGNUM_BOUND; signum++)
+        for (signum = 0; signum <= SIGNUM_BOUND; signum++)
           if (sig2str (signum, signame) == 0)
             print_table_row (num_width, signum, name_width, signame);
     }
@@ -165,7 +165,7 @@ list_signals (bool table, char *const *argv)
               printf ("%d\n", signum);
           }
       else
-        for (signum = 1; signum <= SIGNUM_BOUND; signum++)
+        for (signum = 0; signum <= SIGNUM_BOUND; signum++)
           if (sig2str (signum, signame) == 0)
             puts (signame);
     }
index 82812eada156005709945f3e534e6ef4d91cbf2a..ed4773f65f1259b1612d93b40ed8092e5339cefd 100755 (executable)
@@ -68,4 +68,7 @@ test -n "$SIG_SEQ" || framework_failure_
 env kill -l -- $SIG_SEQ || fail=1
 env kill -t -- $SIG_SEQ || fail=1
 
+# Verify first signal number listed is 0
+test $(env kill -l $(env kill -l | head -n1)) = 0 || fail=1
+
 Exit $fail