From 981d60d2182ee5fa4d5b0bf3e25d61dd8320656b Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 29 Jul 2010 16:40:45 +0000 Subject: kill: Stop processing if a syntactically invalid pid is encountered. So a command like kill _HUP 1 now fails without sending SIGTERM to init. The behaviour when kill(2) fails remains unchanged: processing continues. This matches other implementations and POSIX and is useful for killing multiple processes at once when some of them may already be gone. PR: bin/40282 --- bin/kill/kill.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/kill/kill.c b/bin/kill/kill.c index 8ee1d85..f4ab2df 100644 --- a/bin/kill/kill.c +++ b/bin/kill/kill.c @@ -123,10 +123,9 @@ main(int argc, char *argv[]) for (errors = 0; argc; argc--, argv++) { pid = strtol(*argv, &ep, 10); - if (!**argv || *ep) { - warnx("illegal process id: %s", *argv); - errors = 1; - } else if (kill(pid, numsig) == -1) { + if (!**argv || *ep) + errx(1, "illegal process id: %s", *argv); + else if (kill(pid, numsig) == -1) { warn("%s", *argv); errors = 1; } -- cgit v1.1