]> granicus.if.org Git - procps-ng/commitdiff
PID -2 to -9 for kill too
authorCraig Small <csmall@enc.com.au>
Wed, 29 Jan 2014 11:28:02 +0000 (22:28 +1100)
committerCraig Small <csmall@enc.com.au>
Wed, 29 Jan 2014 11:28:02 +0000 (22:28 +1100)
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

diff --git a/skill.c b/skill.c
index 1c99985b8332ddf156dc1032695fe10851e81635..60ed274604ac03535456f6497cd00003330c880e 100644 (file)
--- a/skill.c
+++ b/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;