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
2010-02-05 11:49:44
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
2010-02-05 11:51:45
+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
2010-02-05 12:14:02
@bmargulies: thx for the clarification!
just somebody
2010-02-05 14:29:45