LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   PPID from /proc file system? (https://www.linuxquestions.org/questions/linux-enterprise-47/ppid-from-proc-file-system-594775/)

sanjaykhuntia 10-26-2007 08:56 AM

PPID from /proc file system?
 
hi,
can anyone please tell me if i can get parent process id form /proc file system in RHEL 4? i know i can get the process id thru a small program from /proc, but i am doubtful about where the ppid is stored?

can anyone give me any idea where i can get ppid in /proc and how to read that value?
a small code will also do fine if one can provide.

Thanks in advance for ur reply,
sanjay

MensaWater 10-26-2007 03:40 PM

cat /proc/<number>/stat

e.g. for PID #14:

cat /proc/14/stat
14 (kblockd/0) S 11 1 1 0 -1 41024 0 0 0 0 0 2336 0 0 10 -5 1 0 258 0 0 4294967295 0 0 0 0 0 0 2147483647 65536 0 0 0 0 17 0 0 0

The 11 in the above (4th field) is the PPID.

To get detailed infromation about what can be found /proc type:
man proc

This gives you the man(ual) page for the proc command which is very detailed. In there if you do search for "ppid" you'll see the explanation that would have led you to the above information.


All times are GMT -5. The time now is 06:25 AM.