tags:

views:

69

answers:

2

I am kind of creating a watchdog which keeps the status log of other processes whose pids are known. I wana know if there is some c++ or c code to get this functionality.

A: 

I don't know if there is a direct way to do it, but you could always do a popen("/bin/ps", "r") and read in the results with fgets() and parse the text output.

Jeremy Friesner
+3  A: 

You can read /proc/{PID}/status and parse the line beginning with "State:".

pau.estalella