summaryrefslogtreecommitdiffstats
path: root/usr.bin/killall
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-09-07 09:13:44 +0000
committertjr <tjr@FreeBSD.org>2003-09-07 09:13:44 +0000
commitf00a5ee89425945bc84b8d85fbf40e5da8ebec26 (patch)
tree9dceceab37ab1ae32a1145fb84b0e409ae89d301 /usr.bin/killall
parent8c8be14d552974727252b624b221441d78f9e0aa (diff)
downloadFreeBSD-src-f00a5ee89425945bc84b8d85fbf40e5da8ebec26.zip
FreeBSD-src-f00a5ee89425945bc84b8d85fbf40e5da8ebec26.tar.gz
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.
Diffstat (limited to 'usr.bin/killall')
-rw-r--r--usr.bin/killall/killall.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c
index 45dcdbb..dfa5734 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);
OpenPOWER on IntegriCloud