aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-04-07 06:00:07 +0000
committerErik Andersen <andersen@codepoet.org>2000-04-07 06:00:07 +0000
commit825aead68b26a5857330972bd1c6adb9f78047ab (patch)
tree41cb71183c7a9bc0812a51f4a16714e400f63170 /procps
parent93d6513d9315fa72d7af4ac2435f8c1e243273cb (diff)
downloadbusybox-825aead68b26a5857330972bd1c6adb9f78047ab.tar.gz
Patch to make killall actually kill all PIDs with the specified name,
rather then busylooping trying to kill the first one until it dies. Should be more efficient now, and will only send one signal to each specified process. -Erik
Diffstat (limited to 'procps')
-rw-r--r--procps/kill.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/procps/kill.c b/procps/kill.c
index 260f4a074..c6dc79f65 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -224,12 +224,18 @@ extern int kill_main(int argc, char **argv)
else {
/* Looks like they want to do a killall. Do that */
while (--argc >= 0) {
- int pid;
-
- while((pid = findPidByName( *argv))) {
- if (kill(pid, sig) != 0)
- fatalError( "Could not kill pid '%d': %s\n", pid, strerror(errno));
+ pid_t* pidList;
+
+ pidList = findPidByName( *argv);
+ for(; pidList && pidList!=0; pidList++) {
+ if (kill(*pidList, sig) != 0)
+ fatalError( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
+ else
+ errorMsg( "killed pid '%d'\n", *pidList);
}
+ /* 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++;
}
}