]> granicus.if.org Git - procps-ng/commitdiff
pkill should be quiet about processes that have gone away
authoralbert <>
Tue, 19 Oct 2004 18:04:31 +0000 (18:04 +0000)
committeralbert <>
Tue, 19 Oct 2004 18:04:31 +0000 (18:04 +0000)
NEWS
pgrep.c

diff --git a/NEWS b/NEWS
index 865f61095104eba8d97cb7c8ab605d766da31930..6e67b3c8b1eba98b68c881089bf22b02fe25ccae 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ pwdx: new command -- thanks Nicholas Miell
 ps: more room for some columns
 watch: passes COLUMNS and LINES in environment
 top: in batch mode, tolerate unknown $TERM -- thanks Daniel Walsh
+pkill: quiet about processes that die before kill()
 
 procps-3.2.2 --> procps-3.2.3
 
diff --git a/pgrep.c b/pgrep.c
index 681b962640ef5c489b42db3360fd586b87402be5..cf6ced95464864957fe98be998dad67149059ecb 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -614,9 +614,10 @@ main (int argc, char **argv)
        if (i_am_pkill) {
                int i;
                for (i = 1; i <= procs[0].num; i++) {
-                       if (kill (procs[i].num, opt_signal) == -1)
-                               fprintf (stderr, "pkill: %ld - %s\n",
-                                        procs[i].num, strerror (errno));
+                       if (kill (procs[i].num, opt_signal) != -1) continue;
+                       if (errno==ESRCH) continue; // gone now, which is OK
+                       fprintf (stderr, "pkill: %ld - %s\n",
+                                procs[i].num, strerror (errno));
                }
        } else {
                if (opt_long)