{"id":200620,"date":"2020-09-21T10:48:07","date_gmt":"2020-09-21T02:48:07","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=200620"},"modified":"2020-09-11T09:49:50","modified_gmt":"2020-09-11T01:49:50","slug":"zz-prosess-shuli","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/zz-prosess-shuli.html","title":{"rendered":"\u4ec0\u4e48\u662f\u50f5\u5c38\u8fdb\u7a0b\u4ee5\u53ca\u5982\u4f55\u5904\u7406"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728UNIX\u7cfb\u7edf\u4e2d\uff0c\u4e00\u4e2a\u8fdb\u7a0b\u7ed3\u675f\u4e86\uff0c\u4f46\u662f\u5176\u7236\u8fdb\u7a0b\u6ca1\u6709\u7b49\u5f85\uff08\u8c03\u7528wait\/waitpid\uff09\u5b83\uff0c\u90a3\u4e48\u5b83\u5c06\u53d8\u6210\u4e00\u4e2a\u50f5\u5c38\u8fdb\u7a0b\u3002\u901a\u8fc7PS\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5176\u5e26\u6709defunct\u7684\u6807\u5fd7\uff0c\u50f5\u5c38\u8fdb\u7a0b\u662f\u4e00\u4e2a\u65e9\u5df2\u6b7b\u4ea1\u7684\u8fdb\u7a0b\uff0c\u4f46\u5728\u8fdb\u7a0b\u8868\u4e2d\u4ecd\u5360\u636e\u4e00\u4e2a\u4f4d\u7f6e<\/strong>\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u4f46\u662f\u5982\u679c\u8be5\u8fdb\u7a0b\u7684\u7236\u8fdb\u7a0b\u5df2\u7ecf\u5148\u7ed3\u675f\u4e86\uff0c\u90a3\u4e48\u8be5\u8fdb\u7a0b\u5c31\u4e0d\u4f1a\u53d8\u6210\u50f5\u5c38\u8fdb\u7a0b\u3002\u56e0\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u7ed3\u675f\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u90fd\u4f1a\u626b\u63cf\u5f53\u524d\u7cfb\u7edf\u4e2d\u6240\u8fd0\u884c\u7684\u6240\u6709\u8fdb\u7a0b\uff0c\u770b\u770b\u6709\u6ca1\u6709\u54ea\u4e2a\u8fdb\u7a0b\u662f\u521a\u521a\u7ed3\u675f\u7684\u8fd9\u4e2a\u8fdb\u7a0b\u7684\u5b50\u8fdb\u7a0b\uff0c\u5982\u679c\u662f\u7684\u8bdd\uff0c\u5c31\u7531init\u8fdb\u7a0b\u6765\u63a5\u7ba1\u4ed6\uff0c\u6210\u4e3a\u4ed6\u7684\u7236\u8fdb\u7a0b\uff0c\u4ece\u800c\u4fdd\u8bc1\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u4f1a\u6709\u4e00\u4e2a\u7236\u8fdb\u7a0b\u3002\u800cinit\u8fdb\u7a0b\u4f1a\u81ea\u52a8wait\u5176\u5b50\u8fdb\u7a0b\uff0c\u56e0\u6b64\u88abInit\u63a5\u7ba1\u7684\u6240\u6709\u8fdb\u7a0b\u90fd\u4e0d\u4f1a\u53d8\u6210\u50f5\u5c38\u8fdb\u7a0b<\/strong>\u3002<\/p>\n

\u4e00\u4e2a\u8fdb\u7a0b\u5728\u8c03\u7528exit\u547d\u4ee4\u7ed3\u675f\u81ea\u5df1\u7684\u751f\u547d\u65f6\u5019\uff0c\u5176\u5b9e\u5b83\u6ca1\u6709\u771f\u6b63\u7684\u88ab\u9500\u6bc1\uff0c\u800c\u662f\u7559\u4e0b\u4e00\u4e2a\u79f0\u4e3a\u50f5\u5c38\u8fdb\u7a0b\u7684\u6570\u636e\u7ed3\u6784\uff08\u7cfb\u7edf\u8c03\u7528exit\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u4f7f\u8fdb\u7a0b\u9000\u51fa\uff0c\u4f46\u4e5f\u4ec5\u4ec5\u9650\u4e8e\u5c06\u4e00\u4e2a\u6b63\u5e38\u7684\u8fdb\u7a0b\u53d8\u6210\u4e00\u4e2a\u50f5\u5c38\u8fdb\u7a0b\uff0c\u5e76\u4e0d\u80fd\u5c06\u5176\u5b8c\u5168\u9500\u6bc1\uff09\u3002\u5728Linux\u8fdb\u7a0b\u7684\u72b6\u6001\u4e2d\uff0c\u50f5\u5c38\u8fdb\u7a0b\u662f\u975e\u5e38\u7279\u6b8a\u7684\u4e00\u79cd\uff0c\u5b83\u5df2\u7ecf\u653e\u5f03\u4e86\u51e0\u4e4e\u6240\u6709\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u6ca1\u6709\u4efb\u4f55\u53ef\u6267\u884c\u4ee3\u7801\uff0c\u4e5f\u4e0d\u80fd\u88ab\u8c03\u5ea6\uff0c\u4ec5\u4ec5\u5728\u8fdb\u7a0b\u5217\u8868\u4e2d\u4fdd\u7559\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u8bb0\u5f55\u5728\u8fdb\u7a0b\u7684\u9000\u51fa\u72b6\u6001\u7b49\u4fe1\u606f\u4f9b\u5176\u4ed6\u8fdb\u7a0b\u6536\u96c6\uff0c\u9664\u6b64\u4e4b\u5916\uff0c\u50f5\u5c38\u8fdb\u7a0b\u4e0d\u5728\u5360\u6709\u4efb\u4f55\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n

\u5b83\u9700\u8981\u7236\u8fdb\u7a0b\u6765\u4e3a\u5b83\u6536\u5c38\u2026\u5982\u679c\u7236\u8fdb\u7a0b\u7ed3\u675f\u4e86\uff0c\u90a3\u4e48init\u8fdb\u7a0b\u4f1a\u81ea\u52a8\u63a5\u624b\u8fd9\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u4e3a\u5b83\u6536\u5c38\uff0c\u5b83\u8fd8\u662f\u80fd\u88ab\u6e05\u9664\u7684\uff0c\u4f46\u662f\u5982\u679c\u7236\u8fdb\u7a0b\u662f\u4e00\u4e2a\u5faa\u73af\uff0c\u4e0d\u4f1a\u7ed3\u675f\uff0c\u90a3\u4e48\u5b50\u8fdb\u7a0b\u5c31\u4f1a\u4e00\u76f4\u4fdd\u6301\u50f5\u5c38\u72b6\u6001\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u7cfb\u7edf\u6709\u65f6\u5019\u4f1a\u6709\u5f88\u591a\u7684\u50f5\u5c38\u8fdb\u7a0b\uff1b<\/p>\n

\u4e3a\u4ec0\u4e48windows\u4e0d\u4f1a\u6709\u50f5\u5c38\u8fdb\u7a0b\uff1f<\/strong><\/div>\n

\u521b\u5efa\u8fdb\u7a0b\u7684\u65b9\u5f0f\u5728Windows(CreateProcess)\u548cLinux\uff08Fork\uff09\u4e0b\u7684\u5dee\u5f02\u8fd8\u662f\u6709\u7684\uff0c\u4f46\u662f\u4e5f\u4e0d\u662f\u5b8c\u5168\u4e0d\u80fd\u7edf\u4e00\uff0c\u9ebb\u70e6\u70b9\u7684\u5c31\u662fWindows\u6ca1\u6709\u50f5\u5c38\u8fdb\u7a0b\u7684\u6982\u5ff5\u5bfc\u81f4\u8fdb\u7a0bID\u4e0d\u80fd\u771f\u6b63\u533a\u522b\u51fa\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u6bd4\u5982\u8bf4\u4e00\u4e2aID100\u7684\u8fdb\u7a0b\u5173\u95ed\u4e86\uff0c\u7136\u540e\u4e00\u4e2a\u65b0\u7684\u8fdb\u7a0b\u542f\u52a8\u540eID\u4e3a100\uff0c\u5e76\u4e14\u7236\u5b50\u8fdb\u7a0b\u4e4b\u95f4\u7684\u8054\u7cfb\u6bd4Linux\u4e0b\u8981\u5f31\u7684\u591a\u3002
\n\u8fdb\u7a0b\u4e4b\u95f4\u76f8\u4e92\u72ec\u7acb\uff1b\u8981\u8fdb\u884c\u7b49\u5f85\u9700\u8981\u663e\u5f0f\u5199\u4ee3\u7801\u3002
\n<\/p>\n

\u67e5\u770b\u50f5\u5c38\u8fdb\u7a0b<\/strong><\/span><\/div>\n

<\/strong><\/p>\n

top>> task (line)>> zombie..<\/pre>\n
\u6e05\u9664\u50f5\u5c38\u8fdb\u7a0b<\/strong> <\/strong><\/span><\/div>\n

\u628a\u7236\u8fdb\u7a0b\u6740\u6389\uff0c\u7236\u8fdb\u7a0b\u6b7b\u540e\uff0c\u50f5\u5c38\u8fdb\u7a0b\u79f0\u4e3a\u201c\u5b64\u513f\u8fdb\u7a0b\u201d\uff0c\u8fc7\u7ee7\u7ed91\u53f7\u8fdb\u7a0binit\uff0cinit\u59cb\u7ec8\u8d1f\u8d23\u6e05\u7406\u50f5\u5c38\u8fdb\u7a0b\uff0c\u5b83\u4ea7\u751f\u7684\u6240\u6709\u50f5\u5c38\u8fdb\u7a0b\u8ddf\u7740\u6d88\u5931\uff1b<\/p>\n

kill<\/strong> <\/strong><\/span><\/div>\n

kill\u547d\u4ee4\u53ef\u4ee5\u5e26\u4fe1\u53f7\u53f7\u7801\u9009\u9879\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u5e26\u3002\u5982\u679c\u6ca1\u6709\u4fe1\u53f7\u53f7\u7801\uff0ckill\u547d\u4ee4\u5c31\u4f1a\u53d1\u51fa\u7ec8\u6b62\u4fe1\u53f7(15)<\/p>\n

killall \u3000\u3000kill -15 \u3000kill -9<\/pre>\n

\u4e00\u822c\u90fd\u4e0d\u80fd\u6740\u6389 defunct\u8fdb\u7a0b..\u3000\u7528\u4e86kill -15,kill -9\u4ee5\u540e \u4e4b\u540e\u53cd\u800c\u4f1a\u591a\u51fa\u66f4\u591a\u7684\u50f5\u5c38\u8fdb\u7a0b<\/p>\n

\u505c\u6b62\u548c\u91cd\u542f\u8fdb\u7a0b<\/strong><\/strong><\/span><\/div>\n

\u6709\u65f6\u5019\u53ea\u60f3\u7b80\u5355\u7684\u505c\u6b62\u548c\u91cd\u542f\u8fdb\u7a0b\u3002\u5982\u4e0b\uff1a<\/p>\n

kill -HUP PID<\/pre>\n

\u8be5\u547d\u4ee4\u8ba9Linux\u548c\u7f13\u7684\u6267\u884c\u8fdb\u7a0b\u5173\u95ed\uff0c\u7136\u540e\u7acb\u5373\u91cd\u542f\u3002\u5728\u914d\u7f6e\u5e94\u7528\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u547d\u4ee4\u5f88\u65b9\u4fbf\uff0c\u5728\u5bf9\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u540e\u9700\u8981\u91cd\u542f\u8fdb\u7a0b\u65f6\u5c31\u53ef\u4ee5\u6267\u884c\u6b64\u547d\u4ee4\u3002<\/p>\n

\u5f88\u591a\u65f6\u5019\uff0c\u4f1a\u6709\u4eba\u5efa\u8bae\u4f60\uff0c\u5982\u679ckill\u6740\u4e0d\u6389\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u5c31\u7528kill -9. \u4e3a\u4ec0\u4e48\uff1f
\nkill\u662fLinux\u4e0b\u5e38\u89c1\u7684\u547d\u4ee4\u3002\u5176man\u624b\u518c\u7684\u529f\u80fd\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n

kill \u2013 send a signal to a process<\/pre>\n

\u660e\u6717\u4e86\uff0c\u5176\u5b9ekill\u5c31\u662f\u7ed9\u67d0\u4e2a\u8fdb\u7a0bid\u53d1\u9001\u4e86\u4e00\u4e2a\u4fe1\u53f7\u3002\u9ed8\u8ba4\u53d1\u9001\u7684\u4fe1\u53f7\u662fSIGTERM\uff0c\u800ckill -9\u53d1\u9001\u7684\u4fe1\u53f7\u662fSIGKILL\uff0c\u5373exit\u3002exit\u4fe1\u53f7\u4e0d\u4f1a\u88ab\u7cfb\u7edf\u963b\u585e\uff0c\u6240\u4ee5kill -9\u80fd\u987a\u5229\u6740\u6389\u8fdb\u7a0b\u3002\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528kill\u53d1\u9001\u5176\u4ed6\u4fe1\u53f7\u7ed9\u8fdb\u7a0b\u3002<\/p>\n

Linux\u7cfb\u7edf\u5bfb\u627e\u548c\u6740\u6389\u50f5\u5c38\u8fdb\u7a0b<\/strong><\/strong><\/div>\n

Linux\u670d\u52a1\u5668\u4e0a\uff0c\u591a\u5c11\u4f1a\u51fa\u73b0\u4e00\u4e9b\u50f5\u5c38\u8fdb\u7a0b\uff0c\u4e0b\u9762\u4ecb\u7ecd\u5982\u4f55\u5feb\u901f\u5bfb\u627e\u548c\u6d88\u706d\u8fd9\u4e9b\u50f5\u5c38\u8fdb\u7a0b\u7684\u65b9\u6cd5\uff1a<\/p>\n

\u9996\u5148\uff0c\u53ef\u4ee5\u4f7f\u7528top\u547d\u4ee4\u6765\u67e5\u770b\u670d\u52a1\u5668\u5f53\u524d\u662f\u5426\u6709\u50f5\u5c38\u8fdb\u7a0b\uff0c\u4e0b\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\u50f5\u5c38\u8fdb\u7a0b\u7684\u63d0\u793a\uff0c\u5982\u679c\u6570\u5b57\u5927\u4e8e0\uff0c\u90a3\u4e48\u610f\u5473\u7740\u670d\u52a1\u5668\u5f53\u524d\u5b58\u5728\u50f5\u5c38\u8fdb\u7a0b\uff1a<\/p>\n

\"\"<\/a><\/p>\n

\u4e0b\u9762\uff0c\u7528ps \u547d\u4ee4\u548c grep\u547d\u4ee4\u5bfb\u627e\u50f5\u5c38\u8fdb\u7a0b\uff1a<\/p>\n

ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]'<\/pre>\n

\u547d\u4ee4\u6ce8\u89e3\uff1a
\n-A \u53c2\u6570\u5217\u51fa\u6240\u6709\u8fdb\u7a0b
\n-o \u81ea\u5b9a\u4e49\u8f93\u51fa\u5b57\u6bb5\uff0c\u6211\u4eec\u8bbe\u5b9a\u663e\u793a\u5b57\u6bb5\u4e3astat\uff08\u72b6\u6001\uff09\uff0cppid\uff08\u7236\u8fdb\u7a0bpid\uff09\uff0cpid\uff08\u8fdb\u7a0bpid\uff09\uff0ccmd\uff08\u547d\u4ee4\u884c\uff09\u8fd9\u56db\u4e2a\u53c2\u6570<\/p>\n

\u56e0\u4e3a\u72b6\u6001\u4e3a z \u6216\u8005 Z\u7684\u8fdb\u7a0b\u4e3a\u50f5\u5c38\u8fdb\u7a0b\uff0c\u6240\u4ee5\u6211\u4eec\u4f7f\u7528grep \u6293\u53d6stat \u72b6\u6001\u4e3azZ\u8fdb\u7a0b\uff1b
\n\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1aZ 12334 12339 \/path\/cmd <\/span>
\n\u8fd9\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 kill -HUP 12339 \u00a0<\/span>\u6765\u6740\u6389\u8fd9\u4e2a\u50f5\u5c38\u8fdb\u7a0b\uff1b
\n\u8fd0\u884c\u540e\uff0c\u5728\u6b64\u8fd0\u884c ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' \u00a0<\/span>\u6765\u786e\u8ba4\u662f\u5426\u5c06\u50f5\u5c38\u8fdb\u7a0b\u6740\u6b7b\uff1b
\n\u5982\u679ckill \u5b50\u8fdb\u7a0b\u7684\u65e0\u6548\uff0c\u53ef\u4ee5\u5c1d\u8bd5kill \u5176\u7236\u8fdb\u7a0b\u6765\u89e3\u51b3\u95ee\u9898\uff0c\u4f8b\u5982\u4e0a\u9762\u7236\u8fdb\u7a0bpid \u4e3a12334\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u8fd0\u884c\u00a0 kill -HUP 12334<\/span> \u6765\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4f46\u662f\u5982\u679c\u8be5\u8fdb\u7a0b\u7684\u7236\u8fdb\u7a0b\u5df2\u7ecf\u5148\u7ed3\u675f\u4e86\uff0c\u90a3\u4e48\u8be5\u8fdb\u7a0b\u5c31\u4e0d\u4f1a\u53d8\u6210\u50f5\u5c38\u8fdb\u7a0b\u3002\u56e0\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u7ed3\u675f\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u90fd\u4f1a\u626b\u63cf\u5f53\u524d\u7cfb\u7edf […]<\/p>\n","protected":false},"author":643,"featured_media":200629,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-200620","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/200620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/643"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=200620"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/200620\/revisions"}],"predecessor-version":[{"id":200668,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/200620\/revisions\/200668"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/200629"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=200620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=200620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=200620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}