Subject: Re: sysinfo(2)
To: Aidan Cully <>
From: Simon Burge <simonb@NetBSD.ORG>
List: tech-kern
Date: 04/10/2000 00:37:17
[ Bcc'd to tech-net, continuing on tech-kern ]

Aidan Cully wrote:

> On Sat, Apr 08, 2000 at 11:11:57PM +1000, Simon Burge wrote:
> > Aidan Cully wrote:
> > 
> > > I think we can use the components of sysctl()'s 'name' parameter to
> > > provide version information for filling out the process table.  Every
> > > time struct proc changes size, KERN_PROC could change value, and get
> > > mapped to compatibility routines for returning the old format
> > > structures from the kernel.  It also allows for fields being removed
> > > from struct kinfo_proc...
> > 
> > The idea I had in mind was not to put a struct proc inside struct
> > kinfo_proc at all, but have each individual field that we want copied
> > over.
> We're in violent agreement, here...  I wasn't thinking too clearly
> when I wrote 'struct proc' there.  Was around 2:20 AM, locally.

Umm, good.  Yes, we are :-)

> > I'd be curious if anyone actually knows now the HP/UX pstat*() index
> > stuff is implemented (bcc'd to someone who may know).  The other option
> > is to forget about the index stuff altogether and do what we currently
> > do - call sysctl() with a null oldp and get the number of "things"
> > available in oldlenp.
> Without some kind of locking, or buffering, it's always going to be
> possible for the tables to change from underneath you when you use a
> series of syscalls to talk to the kernel...  Using this approach, the
> size of the table can change, but nothing else.

I think, without checking, that either ps or sysctl adds some slop so
that, for example, n+10 processes are requested after determining how
many processes there are.