Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Feb 2004 13:23:19 -0500 (EST)
From:      Daniel Eischen <eischen@vigrid.com>
To:        Scott Long <scottl@freebsd.org>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: Should ps -p list threads?
Message-ID:  <Pine.GSO.4.10.10402131318510.20325-100000@pcnet5.pcnet.com>
In-Reply-To: <20040212124357.B21291@pooker.samsco.home>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 12 Feb 2004, Scott Long wrote:

> On Thu, 12 Feb 2004, Daniel Eischen wrote:
> > On Thu, 12 Feb 2004, Julian Elischer wrote:
> > >
> > > The origianlpatch had _H show threads and normal ps did not..
> > > I don't know why this is as it is...
> >
> > Because it didn't take into account other 'ps' options.  Enabling
> > or disabling thread info should be an option for all KERN_PROC_foo,
> > not a separate option.  If I were to change it, I would add
> >
> > 	#define	KERN_PROC_THREADS	0x10000
> >
> > to <sys/sysctl.h>.  Then allow:
> >
> > 	mib[0] = CTL_KERN;
> > 	mib[1] = KERN_PROC;
> > 	mib[2] = KERN_PROC_UID | KERN_PROC_THREADS;
> > 	mib[3] = pid;
> >
> > ...
> >
> 
> Yeah, it's probably cleaner that way.  Still, you'll have to deal with
> KERN_PROC_PROC vs. KERN_PROC_ALL.  Maybe just remove both and have
> KERN_PROC_THREAD be a modifier for KERN_PROC_PID.  Are you
> willing to do the kernel work for this too?

Tested and working patch at:

  http://people.freebsd.org/~deischen/kse/sysctl.diffs.021304

The sysctl interface doesn't work as I expected.  It didn't
seem to like "holey" slots, so I couldn't do:

	#define KERN_PROC_ALL           0       /* everything */
	...
	#define KERN_PROC_SV_NAME       9       /* get syscall vector name */
	#define KERN_PROC_THREADS	0x10	/* include threads */

Instead I had to add separate defines for each one:

	#define KERN_PROC_PID_TD        10      /* by process id */
	#define KERN_PROC_PGRP_TD       11      /* by process group id */
	#define KERN_PROC_SESSION_TD    12      /* by session of pid */
	#define KERN_PROC_TTY_TD        13      /* by controlling tty */
	#define KERN_PROC_UID_TD        14      /* by effective uid */
	#define KERN_PROC_RUID_TD       15      /* by real uid */
	#define KERN_PROC_PROC_TD       16      /* only return procs */

-- 
Dan Eischen



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10402131318510.20325-100000>