Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

function to get list of processes that are running with their names and pid

8 views
Skip to first unread message

Mev...@gmail.com

unread,
Nov 27, 2008, 10:23:47 AM11/27/08
to
Please, someone knows any function that can be used on los178 2.3.0
that do that? It must be function in C, without using shell because
production environment don't have shell. I need something like ps
command in shell.

Thanks,
Martin

dion....@gmail.com

unread,
Dec 3, 2008, 7:14:53 PM12/3/08
to

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)

}

0 new messages