From 2c801d3d5fd9996e7581d18fb94ce489f0f5bbe6 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Sun, 7 Sep 2003 09:13:44 +0000 Subject: [PATCH] Use KERN_PROC_PROC instead of KERN_PROC_ALL when enumerating processes so that we kill each process once, not once for every thread it owns. This avoids "No such process" warnings when killing threaded processes. --- usr.bin/killall/killall.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c index 45dcdbb1b7cb..dfa5734e0141 100644 --- a/usr.bin/killall/killall.c +++ b/usr.bin/killall/killall.c @@ -266,19 +266,16 @@ main(int ac, char **av) size = 0; mib[0] = CTL_KERN; mib[1] = KERN_PROC; - mib[2] = KERN_PROC_ALL; + mib[2] = KERN_PROC_PROC; mib[3] = 0; - miblen = 3; + miblen = 4; - if (user && mib[2] == KERN_PROC_ALL) { + if (user) { mib[2] = KERN_PROC_RUID; mib[3] = uid; - miblen = 4; - } - if (tty && mib[2] == KERN_PROC_ALL) { + } else if (tty) { mib[2] = KERN_PROC_TTY; mib[3] = tdev; - miblen = 4; } st = sysctl(mib, miblen, NULL, &size, NULL, 0);