aboutsummaryrefslogtreecommitdiff
path: root/procps/kill.c
diff options
context:
space:
mode:
authorerik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-04-07 06:00:07 +0000
committererik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-04-07 06:00:07 +0000
commitd383175e820952ac4f761d4d739d04fd718b43d9 (patch)
tree41cb71183c7a9bc0812a51f4a16714e400f63170 /procps/kill.c
parent8a9842dffbfd6d8ae7ffcf1d56247bd7a71d48dd (diff)
downloadbusybox-w32-d383175e820952ac4f761d4d739d04fd718b43d9.tar.gz
busybox-w32-d383175e820952ac4f761d4d739d04fd718b43d9.tar.bz2
busybox-w32-d383175e820952ac4f761d4d739d04fd718b43d9.zip
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 git-svn-id: svn://busybox.net/trunk/busybox@437 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'procps/kill.c')
-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)
224 else { 224 else {
225 /* Looks like they want to do a killall. Do that */ 225 /* Looks like they want to do a killall. Do that */
226 while (--argc >= 0) { 226 while (--argc >= 0) {
227 int pid; 227 pid_t* pidList;
228 228
229 while((pid = findPidByName( *argv))) { 229 pidList = findPidByName( *argv);
230 if (kill(pid, sig) != 0) 230 for(; pidList && pidList!=0; pidList++) {
231 fatalError( "Could not kill pid '%d': %s\n", pid, strerror(errno)); 231 if (kill(*pidList, sig) != 0)
232 fatalError( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
233 else
234 errorMsg( "killed pid '%d'\n", *pidList);
232 } 235 }
236 /* Note that we don't bother to free the memory
237 * allocated in findPidByName(). It will be freed
238 * upon exit, so we can save a byte or two */
233 argv++; 239 argv++;
234 } 240 }
235 } 241 }