I tried google, but found getppid() which gets the parent pid of the current process.
I need something like getppid(some_other_pid), is there such a thing? Basically takes the pid of some process and returns the parent process’ pid.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think the simplest thing would be to open "/proc" and parse the contents.
You’ll find the ppid as the 4th parameter of /proc/pid/stat
In C, libproc has a
get_proc_statsfunction for parsing that file: see Given a child PID how can you get the parent PID for an example.