54 lines
1.5 KiB
Diff
54 lines
1.5 KiB
Diff
From 39210a89debaff023fa97250bee63c57fe9dfcfb Mon Sep 17 00:00:00 2001
|
|
From: Craig Small <csmall@enc.com.au>
|
|
Date: Wed, 29 Jan 2014 22:28:02 +1100
|
|
Subject: [PATCH] PID -2 to -9 for kill too
|
|
|
|
Commit 4359cf069819d9fb53493933e00d9af5c37bced5 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.
|
|
---
|
|
skill.c | 16 +++++++++-------
|
|
1 file changed, 9 insertions(+), 7 deletions(-)
|
|
|
|
diff --git skill.c skill.c
|
|
index 1c99985..60ed274 100644
|
|
--- skill.c
|
|
+++ skill.c
|
|
@@ -195,7 +195,8 @@ static void check_proc(int pid, struct run_time_conf_t *run_time)
|
|
if (i == -1)
|
|
goto closure;
|
|
}
|
|
- read(fd, buf, 128);
|
|
+ if (read(fd, buf, 128) <= 0)
|
|
+ goto closure;
|
|
buf[127] = '\0';
|
|
tmp = strrchr(buf, ')');
|
|
*tmp++ = '\0';
|
|
@@ -477,15 +478,16 @@ static void __attribute__ ((__noreturn__))
|
|
display_kill_version();
|
|
exit(EXIT_SUCCESS);
|
|
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)) {
|
|
xwarnx(_("invalid argument %c"), optopt);
|
|
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;
|
|
break;
|
|
--
|
|
1.7.9.2
|
|
|