killall5: return 2 if no processes got killed
authorUros Vampl <mobile.leecher@gmail.com>
Mon, 16 Dec 2013 16:44:58 +0000 (17:44 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 16 Dec 2013 16:44:58 +0000 (17:44 +0100)
function                                             old     new   delta
kill_main                                            943     992     +49

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
procps/kill.c

index cd189bcd61a235648c1c5ce76b83a9405070e6a5..8e4213730d18b86e4748aa5df9d3bab7791e3568 100644 (file)
@@ -158,7 +158,8 @@ int kill_main(int argc, char **argv)
        if (killall5) {
                pid_t sid;
                procps_status_t* p = NULL;
-               int ret = 0;
+               /* compat: exitcode 2 is "no one was signaled" */
+               int ret = 2;
 
                /* Find out our session id */
                sid = getsid(pid);
@@ -170,6 +171,7 @@ int kill_main(int argc, char **argv)
                        int i;
 
                        if (p->sid == (unsigned)sid
+                        || p->sid == 0 /* compat: kernel thread, don't signal it */
                         || p->pid == (unsigned)pid
                         || p->pid == 1
                        ) {
@@ -200,6 +202,7 @@ int kill_main(int argc, char **argv)
                                        goto dont_kill;
                        }
                        kill(p->pid, signo);
+                       ret = 0;
  dont_kill: ;
                }
  resume: