{"id":263309,"date":"2023-03-06T08:44:52","date_gmt":"2023-03-06T00:44:52","guid":{"rendered":"https:\/\/gulass.cn\/?p=263309"},"modified":"2023-02-03T23:45:43","modified_gmt":"2023-02-03T15:45:43","slug":"linux-ppid","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-ppid.html","title":{"rendered":"\u5728 Linux \u4e2d\u5982\u4f55\u67e5\u627e\u7236\u8fdb\u7a0b PPID\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5185\u6838\u521b\u5efa\u7684\u8fdb\u7a0b\u79f0\u4e3a\u201c\u7236\u8fdb\u7a0b\u201d\u3002\u4ece\u7236\u8fdb\u7a0b\u6d3e\u751f\u6216\u4ea7\u751f\u7684\u8fdb\u7a0b\u79f0\u4e3a\u201c\u5b50\u8fdb\u7a0b\u201d\u3002\u7236\u8fdb\u7a0b\u53ef\u80fd\u7531\u591a\u4e2a\u5b50\u8fdb\u7a0b\u7ec4\u6210\uff0c\u6bcf\u4e2a\u5b50\u8fdb\u7a0b\u90fd\u5177\u6709\u552f\u4e00\u7684PID\uff08\u8fdb\u7a0b ID\uff09\u4f46\u5171\u4eab\u76f8\u540c\u7684 PPID\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u63a2\u8ba8\u4e86\u53ef\u7528\u4e8e\u67e5\u627e Linux \u7cfb\u7edf\u4e0a\u7684\u7236\u8fdb\u7a0b ID (PPID) \u6216\u8fdb\u7a0b\u7684\u5404\u79cd\u65b9\u6cd5\u3002<\/p>\n

PID \u548c PPID \u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/strong><\/div>\n

\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u5e76\u8fd0\u884c\u7684\u7a0b\u5e8f\u79f0\u4e3a\u8fdb\u7a0b\u3002\u4e00\u65e6\u542f\u52a8\uff0c\u8fdb\u7a0b\u5c06\u83b7\u5f97\u4e00\u4e2a\u552f\u4e00\u7f16\u53f7\uff0c\u79f0\u4e3a\u8fdb\u7a0b ID (\u00a0PID\u00a0)\uff0c\u5728\u7cfb\u7edf\u4e2d\u552f\u4e00\u6807\u8bc6\u5b83\u3002\u53ef\u4ee5\u968f\u65f6\u4f7f\u7528\u5176PID\u5f15\u7528\u8be5\u8fdb\u7a0b\u3002\u4f8b\u5982\uff0c\u8981\u7ec8\u6b62\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u60a8\u5fc5\u987b\u5148\u77e5\u9053\u5b83\u7684PID\u3002<\/p>\n

\u9664\u4e86PID\u4e4b\u5916\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u8fd8\u88ab\u5206\u914d\u4e86\u4e00\u4e2a\u7236\u8fdb\u7a0bID\u00a0(\u00a0PPID\u00a0)\uff0c\u663e\u793a\u662f\u54ea\u4e2a\u8fdb\u7a0b\u751f\u6210\u4e86\u5b83\u3002\u56e0\u6b64\uff0cPPID\u662f\u8fdb\u7a0b\u7236\u8fdb\u7a0b\u7684PID\u3002<\/p>\n

\u4e3a\u4e86\u8bf4\u660e\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u5047\u8bbePID\u4e3a5050\u7684\u8fdb\u7a0b5\u542f\u52a8\u8fdb\u7a0b6\u3002\u8fdb\u7a0b 6 \u5c06\u88ab\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684PID\uff0c\u4f8b\u59826670\uff0c\u4f46\u4ecd\u5c06\u88ab\u5206\u914dPPID\u00a05050\u3002<\/p>\n

\u8fd9\u91cc\u7684\u7236\u8fdb\u7a0b\u662f\u8fdb\u7a0b5\uff0c\u5b50\u8fdb\u7a0b\u662f6\u3002\u5b50\u8fdb\u7a0b\u88ab\u5206\u914d\u4e86\u4e00\u4e2a\u552f\u4e00\u7684PID\u4f46PPID\u4e0e\u7236\u8fdb\u7a0b\u7684 PID \u76f8\u540c\uff08\u8fdb\u7a0b 5\uff09<\/p>\n

\u5355\u4e2a\u7236\u8fdb\u7a0b\u53ef\u4ee5\u542f\u52a8\u591a\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u6bcf\u4e2a\u5b50\u8fdb\u7a0b\u90fd\u6709\u552f\u4e00\u7684 PID \u4f46\u90fd\u5171\u4eab\u76f8\u540c\u7684PPID\u3002<\/p>\n

\u5728 Linux \u4e2d\u67e5\u627e\u7236\u8fdb\u7a0b ID (PPID)<\/strong><\/div>\n

\u5728 Linux \u7cfb\u7edf\u4e0a\u67e5\u627e\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684PPID\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a<\/p>\n

    \n
  • \u4f7f\u7528 pstree \u547d\u4ee4\u3002<\/li>\n
  • \u4f7f\u7528 ps \u547d\u4ee4\u3002<\/li>\n<\/ul>\n
    \u4f7f\u7528 pstree \u547d\u4ee4\u67e5\u627e Linux \u8fdb\u7a0b PPID<\/strong><\/div>\n

    pstree\u547d\u4ee4\u662f\u4e00\u79cd\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5b83\u4ee5\u6811\u7684\u5f62\u5f0f\u663e\u793a\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\uff0c\u8fd9\u4f7f\u5f97\u5728\u5c42\u6b21\u7ed3\u6784\u4e2d\u663e\u793a\u8fdb\u7a0b\u6210\u4e3a\u4e00\u79cd\u65b9\u4fbf\u7684\u65b9\u5f0f\u3002\u5b83\u4ee5\u6811\u72b6\u5c42\u6b21\u7ed3\u6784\u663e\u793a\u7236\u5b50\u5173\u7cfb\u3002<\/p>\n

    \u901a\u8fc7\u8be5 -p\u9009\u9879\uff0cpstree\u663e\u793a\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u7236\u8fdb\u7a0b\u53ca\u5176\u76f8\u5e94\u7684\u5b50\u8fdb\u7a0b\u548c\u5404\u81ea\u7684 PID\u3002<\/p>\n

    linuxmi@linuxmi \/home\/linuxmi\/www.linuxmi.com\r\n\u26a1 pstree -p<\/pre>\n

    \"\"<\/p>\n

    \u5728\u6811\u5c42\u6b21\u7ed3\u6784\u4e2d\u663e\u793a Linux \u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b<\/p>\n

    \u4ece\u8f93\u51fa\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7236\u8fdb\u7a0b ID \u548c\u5b50\u8fdb\u7a0b ID\u3002<\/p>\n

    \u4e3a\u4e86\u6f14\u793a\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5 Mozilla Firefox \u7684 PPID \u4ee5\u53ca\u6574\u4e2a\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784\uff1a<\/p>\n

    linuxmi@linuxmi \/home\/linuxmi\/www.linuxmi.com                                      \r\n\u26a1 pstree -p | grep 'firefox'<\/pre>\n

    \"\"<\/p>\n

    \u67e5\u627e Linux \u8fdb\u7a0b\u7684 PPID<\/p>\n

    \u4ece\u8f93\u51fa\u4e2d\u53ef\u4ee5\u770b\u51fa Firefox \u7684PPID \u4e3a 21401\uff0c\u5176\u4f59\u4e3a\u5b50\u8fdb\u7a0b\u7684PID\u3002<\/p>\n

    \u8981\u4ec5\u663e\u793a Firefox \u7684PPID\u5e76\u8df3\u8fc7\u5176\u4f59\u8f93\u51fa\uff0c\u8bf7\u5c06\u8f93\u51fa\u901a\u8fc7\u7ba1\u9053\u4f20\u9012\u7ed9 head \u547d\u4ee4\u4ee5-1\u663e\u793a\u7b2c\u4e00\u884c\u3002<\/p>\n

    linuxmi@linuxmi \/home\/linuxmi\/www.linuxmi.com                                      \r\n\u26a1 pstree -p | grep 'firefox' | head -1<\/pre>\n

    \"\"<\/p>\n

    \u6253\u5370 Linux \u8fdb\u7a0b\u7684 PPID<\/p>\n

    \u4f7f\u7528 ps \u547d\u4ee4\u67e5\u627e Linux \u8fdb\u7a0b PPID<\/strong><\/div>\n

    \u67e5\u627e\u8fdb\u7a0bPPID\u7684\u53e6\u4e00\u4e2a\u9009\u9879\u662f ps \u547d\u4ee4\uff0c\u8fd9\u662f\u4e00\u4e2a\u5e7f\u6cdb\u4f7f\u7528\u7684\u547d\u4ee4\uff0c\u7528\u4e8e\u663e\u793aLinux \u7cfb\u7edf\u4e0a\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u3002<\/p>\n

    \u5f53\u4e0e\u8be5-ef\u9009\u9879\u4e00\u8d77\u4f7f\u7528\u65f6\uff0cps \u547d\u4ee4\u4f1a\u5217\u51fa\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u53ca\u5176\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982UID\u3001PID\u3001PPID\u7b49\u3002<\/p>\n

    linuxmi@linuxmi \/home\/linuxmi\/www.linuxmi.com                                      \r\n\u26a1 ps -ef<\/pre>\n

    \"\"<\/p>\n

    \u4f7f\u7528 PID \u5217\u51fa\u6b63\u5728\u8fd0\u884c\u7684 Linux \u8fdb\u7a0b<\/p>\n

    \u8981\u7f29\u5c0f\u8303\u56f4\u5e76\u663e\u793a\u7279\u5b9a\u8fdb\u7a0b\u7684PPID\uff0c\u4f8b\u5982Firefox\uff0c\u8bf7\u4f20\u9012-e\u200b\u9009\u9879\u5e76\u5c06\u8f93\u51fa\u901a\u8fc7\u7ba1\u9053\u4f20\u9012\u7ed9 grep \u547d\u4ee4\uff0c\u5982\u56fe\u6240\u793a\uff1a<\/p>\n

    linuxmi@linuxmi \/home\/linuxmi\/www.linuxmi.com                                      \r\n\u26a1 ps -e | grep 'firefox'\r\n  21401 ?        00:00:11 firefox<\/pre>\n

    \"\"<\/p>\n

    \u67e5\u627e Linux \u8fdb\u7a0b PID<\/p>\n

    \u518d\u4e00\u6b21\uff0c\u4ece\u8f93\u51fa\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230 Firefox \u7684 PPID \u662f 21401\u3002<\/p>\n

    \u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u6f14\u793a\u4e86\u5982\u4f55\u5728 Linux \u7cfb\u7edf\u4e0a\u627e\u5230\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684 PPID\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 pstree \u547d\u4ee4\u6216 ps \u547d\u4ee4\u6765\u8fbe\u5230\u76f8\u540c\u7684\u76ee\u6807\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u63a2\u8ba8\u4e86\u53ef\u7528\u4e8e\u67e5\u627e Linux \u7cfb\u7edf\u4e0a\u7684\u7236\u8fdb\u7a0b ID (PPID) \u6216\u8fdb\u7a0b\u7684\u5404\u79cd\u65b9\u6cd5\u3002 \u52a0\u8f7d\u5230\u5185 […]<\/p>\n","protected":false},"author":323,"featured_media":260403,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-263309","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/263309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=263309"}],"version-history":[{"count":3,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/263309\/revisions"}],"predecessor-version":[{"id":263320,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/263309\/revisions\/263320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/260403"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=263309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=263309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=263309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}