Programmatically get parent pid of another process?

后端 未结 6 1104
北恋
北恋 2020-12-02 23:12

I tried google, but found getppid() which gets the parent pid of the current process.

I need something like getppid(some_other_pid)

6条回答
  •  鱼传尺愫
    2020-12-02 23:42

    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

提交回复
热议问题