aboutsummaryrefslogtreecommitdiff
path: root/bin/kill
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2010-07-29 16:40:45 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2010-07-29 16:40:45 +0000
commit9e7839f6328cbab2a6548d521b3a65790c572a12 (patch)
tree96b35aa48056a1f67e7157984db2048c25271406 /bin/kill
parent8a5216d5d8fe5df6088fb75f923f213170599402 (diff)
downloadsrc-9e7839f6328cbab2a6548d521b3a65790c572a12.tar.gz
src-9e7839f6328cbab2a6548d521b3a65790c572a12.zip
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
Notes
Notes: svn path=/head/; revision=210613
Diffstat (limited to 'bin/kill')
-rw-r--r--bin/kill/kill.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/bin/kill/kill.c b/bin/kill/kill.c
index 8ee1d85d398f..f4ab2df3e01a 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;
}