tags:

views:

80

answers:

3

i need to read the list of current running process into a C++ program. I know that one way to do is to use ps command and other is to read /proc file system but i want to know how one can get names of processes by reading /proc file system. also is there any other way to read the list.

+2  A: 

There is no other way to read the list, /proc exists for this purpose. The simplest way to find out exactly how to do this job would be to read the source for procps, which may include a library to do most of the work for you.

Andrew McGregor
A: 

You can read all information from /proc/<process pid>/. I guess the file cmdline and the link exe in each of these directories will be relevant for you.

AndiDog
+2  A: 

you might want to try out libstatgrab, it should be able to give you unified access to that information on many different operating systems. It will still open /proc on GNU/Linux, but you won't know.

just somebody
@bmargulies: thx for the clarification!
just somebody