Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2004 12:11:01 -0500
From:      Craig Rodrigues <rodrigc@crodrigues.org>
To:        freebsd-threads@freebsd.org
Cc:        scottl@freebsd.org
Subject:   Re: Should ps -p list threads?
Message-ID:  <20040212171101.GA72641@crodrigues.org>
In-Reply-To: <Pine.GSO.4.10.10402121116210.15084-100000@pcnet5.pcnet.com>
References:  <402B03B7.1000104@freebsd.org> <Pine.GSO.4.10.10402121116210.15084-100000@pcnet5.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Feb 12, 2004 at 11:16:57AM -0500, Daniel Eischen wrote:
> But 'ps' without -H seems to display KSEs where it shouldn't.

I looked in the source code of ps,
specifically in src/bin/ps/ps.c

If you type just 'ps', this code gets executed in ps.c:

   351         if (nuids == 1) {
   352                 what = KERN_PROC_UID;
   353                 flag = *uids;
   354         } 

   371         if ((kp = kvm_getprocs(kd, what, flag, &nentries)) == 0 || nentr
ies < 0)
   372                 errx(1, "%s", kvm_geterr(kd));



If you type 'ps -H', this code gets executed in ps.c:

194                     case 'H':
195                             showthreads = 1;
196                             break;
 
351             if (nuids == 1) {
352                     what = KERN_PROC_UID;
353                     flag = *uids;

371             if ((kp = kvm_getprocs(kd, what, flag, &nentries)) == 0 || nentries < 0)
372                     errx(1, "%s", kvm_geterr(kd));




So, I am not sure if this is a bug in kvm_getprocs() or in ps.c,
but the result is that if you type ps or ps -H, they
both display KSEs.  Probably just typing ps should not display
them.

Any idea what the problem is?
-- 
Craig Rodrigues        
http://crodrigues.org
rodrigc@crodrigues.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040212171101.GA72641>