Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道可以从中获取 ppid 信息,/proc/PID/status但我只想将其用作备份计划。
/proc/PID/status
那么,是否可以通过提供 PID 编号来获得 PPID?getppid(2)只能获取当前进程的 PPID,因此在这种情况下没有帮助。
getppid(2)
任何想法?谢谢你。
我认为您可以使用 get_proc_stats 函数来执行此操作。但是你需要安装 libproc-dev 库。
这是一个例子:
proc_t p_info; get_proc_stats(pid_num, &p_info); int parent_pid = p_info.ppid;