From 25fdca73f1e1a681ab8505dcc475a5925b53b391 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 31 Jul 2022 09:22:12 -0500 Subject: [PATCH] Tweak error handling so "kill 1" doesn't say unknown pid 1: not permitted. --- toys/posix/kill.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toys/posix/kill.c b/toys/posix/kill.c index 2eaba031..2f47f60f 100644 --- a/toys/posix/kill.c +++ b/toys/posix/kill.c @@ -144,8 +144,9 @@ void kill_main(void) while (*args) { char *arg = *(args++); - pid = strtol(arg, &tmp, 10); - if (*tmp || kill(pid, signum) < 0) error_msg("unknown pid '%s'", arg); + pid = estrtol(arg, &tmp, 10); + if (!errno && *tmp) errno = ESRCH; + if (errno || kill(pid, signum)<0) perror_msg("bad pid '%s'", arg); } } } -- 2.39.2