Thanks,
Martin
Yea, I had the same problem! I've inspected the source code for ps and
they use the /dev/mem device with an offset to the process tables.
This offset (address) in turn is determined with info(_I_PROCTAB). For
other info types see /usr/include/info.h. This is a very handy mehod
for all kinds of kernel info & tables (although propably only usable
by user 0)
It goes something like this : (have not tested it myself but you'll
get the idea at least)
nproc = info(_I_NPROCTAB);
fd = open("/dev/mem", 0);
lseek(fd, info(_I_PROCTAB), 0);
for (i = 0; i < nproc ; i++)
{
read(fd, pbuff, sizeof(struct pentry));
// pbuff will now contan the process entry (struct pentry in proc.h)
}