PID -2 to -9 for kill too
Commit 4359cf0698
restored kill's ability
to kill PID -1. This however left PIDs -2 to -9 (or rather process
groups 2 to 9) still having this problem. The check is now generically
looking for a digit and parses it correctly.
This commit is contained in:
parent
5a34ff0a99
commit
39210a89de
16
skill.c
16
skill.c
@ -195,7 +195,8 @@ static void check_proc(int pid, struct run_time_conf_t *run_time)
|
|||||||
if (i == -1)
|
if (i == -1)
|
||||||
goto closure;
|
goto closure;
|
||||||
}
|
}
|
||||||
read(fd, buf, 128);
|
if (read(fd, buf, 128) <= 0)
|
||||||
|
goto closure;
|
||||||
buf[127] = '\0';
|
buf[127] = '\0';
|
||||||
tmp = strrchr(buf, ')');
|
tmp = strrchr(buf, ')');
|
||||||
*tmp++ = '\0';
|
*tmp++ = '\0';
|
||||||
@ -477,15 +478,16 @@ static void __attribute__ ((__noreturn__))
|
|||||||
display_kill_version();
|
display_kill_version();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
case '?':
|
case '?':
|
||||||
/* Special case is -1 which means all except init */
|
|
||||||
if (optopt == '1') {
|
|
||||||
if (kill(-1, signo) != 0)
|
|
||||||
exitvalue = EXIT_FAILURE;
|
|
||||||
exit(exitvalue);
|
|
||||||
}
|
|
||||||
if (!isdigit(optopt)) {
|
if (!isdigit(optopt)) {
|
||||||
xwarnx(_("invalid argument %c"), optopt);
|
xwarnx(_("invalid argument %c"), optopt);
|
||||||
kill_usage(stderr);
|
kill_usage(stderr);
|
||||||
|
} else {
|
||||||
|
/* Special case for signal digit negative
|
||||||
|
* PIDs */
|
||||||
|
pid = (long)('0' - optopt);
|
||||||
|
if (kill((pid_t)pid, signo) != 0)
|
||||||
|
exitvalue = EXIT_FAILURE;
|
||||||
|
exit(exitvalue);
|
||||||
}
|
}
|
||||||
loop=0;
|
loop=0;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user