diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2012-04-17 23:17:54 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2012-04-17 23:17:54 +0000 |
commit | 9423fd636fbb829a3beb96e6bf91a8435aca0dac (patch) | |
tree | 662e13cd8db382c4a64c9981a968e8662067d7d4 /lib/libkvm | |
parent | 0dda1e76ea40698dad18b59045a473096026880e (diff) |
Make it optional for kvm_getprocs() (and related sysctl) to return
thread information.
Add a KERN_PROC_SHOW_THREADS flag that has to be set in order to get the
thread info and make it off by default. This creates backwards compatibility
for applications that relied on a given size/number of items to be returned.
Modify ps(1) and top(1) accordingly.
Okay guenther@.
Diffstat (limited to 'lib/libkvm')
-rw-r--r-- | lib/libkvm/kvm_proc2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libkvm/kvm_proc2.c b/lib/libkvm/kvm_proc2.c index 31b6db78cd1..8c4dd7a148e 100644 --- a/lib/libkvm/kvm_proc2.c +++ b/lib/libkvm/kvm_proc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc2.c,v 1.12 2012/04/14 12:15:21 guenther Exp $ */ +/* $OpenBSD: kvm_proc2.c,v 1.13 2012/04/17 23:17:53 pirofti Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -119,6 +119,10 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, struct plimit limits, *limp; pid_t process_pid, parent_pid, leader_pid; int cnt = 0; + int dothreads = 0; + + dothreads = op & KERN_PROC_SHOW_THREADS; + op &= ~KERN_PROC_SHOW_THREADS; for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) { if (KREAD(kd, (u_long)p, &proc)) { @@ -313,6 +317,10 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, bp += esize; ++cnt; } + + if (!dothreads) + continue; + FILL_KPROC(&kp, do_copy_str, &proc, &process, &pcred, &ucred, &pgrp, p, proc.p_p, &sess, vmp, limp, sap, 1); |