+ in the interest of robustness, I added
[oweals/busybox.git] / kill.c
diff --git a/kill.c b/kill.c
index 260f4a07428dd85e116de10660b6af6bd7c8138a..db4842457595cfff0772840f74fd9aa50e1903ca 100644 (file)
--- a/kill.c
+++ b/kill.c
@@ -224,12 +224,16 @@ extern int kill_main(int argc, char **argv)
        else {
                /* Looks like they want to do a killall.  Do that */
                while (--argc >= 0) {
-                       int pid;
+                       pid_t* pidList;
 
-                       while((pid = findPidByName( *argv))) {
-                               if (kill(pid, sig) != 0) 
-                                       fatalError( "Could not kill pid '%d': %s\n", pid, strerror(errno));
+                       pidList = findPidByName( *argv);
+                       for(; pidList && pidList!=0; pidList++) {
+                               if (kill(*pidList, sig) != 0) 
+                                       fatalError( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
                        }
+                       /* Note that we don't bother to free the memory
+                        * allocated in findPidByName().  It will be freed
+                        * upon exit, so we can save a byte or two */
                        argv++;
                }
        }