From 0737ba9e8dd19c101bee7798170a7ad8f5c90c40 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 26 Aug 2021 17:33:42 -0700 Subject: [PATCH] kill: allow `kill -0` for testing process existence. Allow num_to_sig(0) so kill doesn't disallow -0 because it can't round-trip, and then teach list_signals() to avoid the special case of signal 0 rather than assume that all the signals it shouldn't print don't have names now signal 0 has the name "0". --- lib/lib.c | 2 +- lib/portability.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/lib.c b/lib/lib.c index 81c89650c..332a0d015 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -931,7 +931,7 @@ void sigatexit(void *handler) // Output a nicely formatted table of all the signals. void list_signals(void) { - int i = 0, count = 0; + int i = 1, count = 0; unsigned cols = 80; char *name; diff --git a/lib/portability.c b/lib/portability.c index f97af60e5..c95a75268 100644 --- a/lib/portability.c +++ b/lib/portability.c @@ -422,6 +422,7 @@ int posix_fallocate(int fd, off_t offset, off_t length) #define SIGNIFY(x) {SIG##x, #x} static const struct signame signames[] = { + {0, "0"}, // POSIX SIGNIFY(ABRT), SIGNIFY(ALRM), SIGNIFY(BUS), SIGNIFY(FPE), SIGNIFY(HUP), SIGNIFY(ILL), SIGNIFY(INT), SIGNIFY(KILL),