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
This commit is contained in:
Jilles Tjoelker 2010-07-29 16:40:45 +00:00
parent 8a5216d5d8
commit 9e7839f632
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=210613

View File

@ -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;
}