diff options
author | jilles <jilles@FreeBSD.org> | 2010-07-29 16:40:45 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-07-29 16:40:45 +0000 |
commit | 981d60d2182ee5fa4d5b0bf3e25d61dd8320656b (patch) | |
tree | 96b35aa48056a1f67e7157984db2048c25271406 /bin/kill | |
parent | df60a3400235054c81244b921ca092966515d305 (diff) | |
download | FreeBSD-src-981d60d2182ee5fa4d5b0bf3e25d61dd8320656b.zip FreeBSD-src-981d60d2182ee5fa4d5b0bf3e25d61dd8320656b.tar.gz |
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
Diffstat (limited to 'bin/kill')
-rw-r--r-- | bin/kill/kill.c | 7 |
1 files 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; } |