{"id":52364,"date":"2025-08-11T13:45:12","date_gmt":"2025-08-11T05:45:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/52364.html"},"modified":"2025-08-11T13:45:12","modified_gmt":"2025-08-11T05:45:12","slug":"linux%e8%bf%9b%e7%a8%8b%e4%bf%a1%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/52364.html","title":{"rendered":"Linux\u8fdb\u7a0b\u4fe1\u53f7"},"content":{"rendered":"<h2>1.\u4fe1\u53f7\u7684\u7406\u89e3<\/h2>\n<\/p>\n<h3>1.1.\u4fe1\u53f7\u7684\u6982\u5ff5<\/h3>\n<\/p>\n<p><span style=\"color:#fe2c24\">1.\u4ec0\u4e48\u662f\u4fe1\u53f7&#xff1f;<\/span><\/p>\n<p>\u4fe1\u53f7:(\u95f9\u949f)\u7ea2\u7eff\u706f&#xff0c;\u4e0a\u8bfe\u94c3\u58f0&#xff0c;\u72fc\u70df&#xff0c;\u7535\u8bdd\u94c3\u58f0,\u809a\u5b50\u53eb&#xff0c;\u6572\u95e8\u58f0&#xff0c;\u8138\u8272\u4e0d\u597d\u00a0<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">2.\u4fe1\u53f7\u662f\u7ed9\u8c01\u7684&#xff1f;<\/span><\/p>\n<p>\u4e0a\u9762\u7684\u4fe1\u53f7\u90fd\u662f\u7ed9\u4eba\u7684 -&gt;\u90a3\u4e48\u6b64\u65f6\u7cfb\u7edf\u7684\u4fe1\u53f7\u5c31\u662f\u7ed9\u8fdb\u7a0b\u7684<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">3.\u4fe1\u53f7\u7684\u4f5c\u7528\u662f\u5e72\u561b\u7528\u7684&#xff1f;<\/span><\/p>\n<p>\u4e2d\u65ad\u6211\u4eec\u4eba\u6b63\u5728\u505a\u7684\u4e8b\u60c5&#xff0c;\u662f\u4e00\u79cd\u4e8b\u4ef6\u7684\u5f02\u6b65\u901a\u77e5\u673a\u5236<\/p>\n<p>1.\u6211\u4eec\u81ea\u4e60\u4e00\u4f1a&#xff0c;\u7b49\u5f20\u4e09\u56de\u6765\u518d\u8bb2&#xff0c;\u6211\u4eec\u7ee7\u7eed\u4e0a\u8bfe&#xff0c;\u4e0a\u8bfe &#8212; \u540c\u6b65<\/p>\n<p>2.\u5f20\u4e09\u53d6\u5feb\u9012&#8211;\u5f02\u6b65<\/p>\n<\/p>\n<p>\u4fe1\u53f7\u662f\u4e00\u79cd\u7ed9\u8fdb\u7a0b\u53d1\u9001\u7684&#xff0c;\u7528\u6765\u8fdb\u884c\u4e8b\u4ef6\u5f02\u6b65\u901a\u77e5\u7684\u673a\u5236!<br \/>\n\u4fe1\u53f7\u7684\u4ea7\u751f&#xff0c;\u76f8\u5bf9\u4e8e\u8fdb\u7a0b\u7684\u8fd0\u884c&#xff0c;\u662f\u5f02\u6b65\u7684!<\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u4fe1\u53f7\u7684\u56db\u4e2a\u57fa\u672c\u7ed3\u8bba&#xff1a;<\/span><\/p>\n<p>1.\u4fe1\u53f7\u5904\u7406&#xff0c;\u8fdb\u7a0b\u5728\u4fe1\u53f7\u6ca1\u6709\u4ea7\u751f\u7684\u65f6\u5019&#xff0c;<span style=\"color:#fe2c24\">\u65e9\u5c31\u77e5\u9053<\/span>\u4fe1\u53f7\u8be5\u5982\u4f55\u5904\u7406\u4e86<br \/>\n2.\u4fe1\u53f7\u7684\u5904\u7406&#xff0c;\u4e0d\u662f\u7acb\u5373\u5904\u7406&#xff0c;\u800c\u662f\u53ef\u4ee5\u7b49\u4e00\u4f1a\u5728\u5904\u7406&#xff0c;\u5408\u9002\u7684\u65f6\u5019&#xff0c;\u8fdb\u884c\u4fe1\u53f7\u7684\u5904\u7406<br \/>\n3.\u4eba\u80fd\u8bc6\u522b\u4fe1\u53f7&#xff0c;\u662f\u63d0\u524d\u88ab\u201d\u6559\u80b2\u201d\u8fc7\u7684&#xff0c;\u8fdb\u7a0b\u4e5f\u662f\u5982\u6b64,OS\u7a0b\u5e8f\u5458\u8bbe\u8ba1\u7684\u8fdb\u7a0b&#xff0c;\u8fdb\u7a0b\u65e9\u5df2\u7ecf<span style=\"color:#fe2c24\">\u5185\u7f6e<\/span>\u4e86\u5bf9\u4e8e\u4fe1\u53f7\u7684\u8bc6\u522b\u548c\u5904\u7406\u65b9\u5f0f!<br \/>\n4.\u4fe1\u53f7\u6e90\u975e\u5e38\u591a-&gt;\u7ed9\u8fdb\u7a0b\u4ea7\u751f\u4fe1\u53f7\u7684&#xff0c;\u4fe1\u53f7\u6e90&#xff0c;\u4e5f\u975e\u5e38\u591a<\/p>\n<\/p>\n<\/p>\n<h3>1.2.\u67e5\u770b\u4fe1\u53f7<\/h3>\n<\/p>\n<p>kill\u00a0 -l:\u67e5\u770b\u4fe1\u53f7<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"277\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054509-68998365dba64.png\" width=\"859\" \/><\/p>\n<\/p>\n<p>\u6bcf\u4e2a\u4fe1\u53f7\u90fd\u6709\u7f16\u53f7\u548c\u5b8f\u5b9a\u4e49\u540d\u79f0&#xff0c;\u8fd9\u4e9b\u5b8f\u5b9a\u4e49\u540d\u79f0\u53ef\u4ee5\u5728signal.h\u53ef\u4ee5\u627e\u5230<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"364\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-6899836634142.png\" width=\"882\" \/><\/p>\n<\/p>\n<p>62\u7684\u4fe1\u53f7\u53ef\u4ee5\u5927\u81f4\u5206\u6210\u4e24\u90e8\u5206&#xff0c;\u7f16\u53f734\u4ee5\u4e0a\u7684\u90fd\u662f\u5b9e\u65f6\u4fe1\u53f7&#xff0c;\u8fd9\u4e9b\u4fe1\u53f7\u5728\u4ec0\u4e48\u6761\u4ef6\u4e0b\u4ea7\u751f\u7684&#xff0c;\u8fd9\u4e9b\u4fe1\u53f7\u7684\u9ed8\u8ba4\u884c\u4e3a\u662f\u4ec0\u4e48\u53ef\u4ee5\u5728 man 7 signal \u4e2d\u67e5\u770b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"478\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366572e9.png\" width=\"726\" \/><\/p>\n<\/p>\n<h3>1.3.\u4fe1\u53f7\u5904\u7406<\/h3>\n<\/p>\n<p>\u4fe1\u53f7\u5904\u7406\u53ef\u4ee5\u5206\u6210\u4e09\u79cd&#xff1a;<\/p>\n<\/p>\n<p>1.\u9ed8\u8ba4\u5904\u7406\u52a8\u4f5c<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; &#034;&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f\u8fdb\u7a0b&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; std::endl;<br \/>\n    signal(SIGINT, SIG_DFL);  \/\/ \u8bbe\u7f6e\u4fe1\u53f7\u9ed8\u8ba4\u5904\u7406\u884c\u4e3a<br \/>\n    while(true){<br \/>\n        std::cout &lt;&lt; &#034;I am a process, I am waiting signal!&#034; &lt;&lt; std::endl;<\/p>\n<p>        sleep(1);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7&#xff1a;<br \/>\n\/*<br \/>\n$ g&#043;&#043; sig.cc -o sig<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;212791<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^C        \/\/ \u8f93\u5165Ctrl&#043;C&#xff0c;\u8fdb\u7a0b\u9000\u51fa&#xff08;SIGINT\u9ed8\u8ba4\u884c\u4e3a&#xff09;<br \/>\n*\/<\/p>\n<p>2.\u81ea\u5b9a\u4e49\u4fe1\u53f7\u5904\u7406\u52a8\u4f5c<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; &#034;&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f\u8fdb\u7a0b&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; std::endl;<br \/>\n    signal(SIGQUIT, handler);  \/\/ SIGQUIT \u4fe1\u53f7\u7f16\u53f7\u901a\u5e38\u4e3a 3<br \/>\n    while(true){<br \/>\n        std::cout &lt;&lt; &#034;I am a process, I am waiting signal!&#034; &lt;&lt; std::endl;<br \/>\n        sleep(1);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7\u53ca\u6ce8\u91ca&#xff1a;<br \/>\n\/*<br \/>\n$ g&#043;&#043; sig.cc -o sig<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;213056<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^\\\\\u6211\u662f&#xff1a;213056&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;3  \/\/ \u6309\u4e0b Ctrl&#043;\\\\ \u89e6\u53d1 SIGQUIT&#xff0c;\u6267\u884c\u81ea\u5b9a\u4e49 handler<\/p>\n<p>\/\/ \u6ce8\u91ca\u6389\u7b2c13\u884c&#xff08;signal\u6ce8\u518c\u4ee3\u7801&#xff09;\u540e&#xff1a;<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;213146<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^\\\\Quit  \/\/ \u6309\u4e0b Ctrl&#043;\\\\ \u89e6\u53d1 SIGQUIT&#xff0c;\u6267\u884c\u9ed8\u8ba4\u884c\u4e3a&#xff08;\u7ec8\u6b62\u8fdb\u7a0b\u5e76\u751f\u6210 core&#xff09;<br \/>\n*\/<\/p>\n<p>3.\u5ffd\u7565\u5904\u7406<\/p>\n<p>#include &lt;iostream&gt;<\/p>\n<p>#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; &#034;&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f\u8fdb\u7a0b&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; std::endl;<br \/>\n    signal(SIGINT, SIG_IGN);  \/\/ \u8bbe\u7f6e\u5ffd\u7565\u4fe1\u53f7\u7684\u5b8f<br \/>\n    while(true){<br \/>\n        std::cout &lt;&lt; &#034;I am a process, I am waiting signal!&#034; &lt;&lt; std::endl;<br \/>\n        sleep(1);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7&#xff1a;<br \/>\n\/*<br \/>\n$ g&#043;&#043; sig.cc -o sig<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;212681<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^C^C^C^C^CI am a process, I am waiting signal! \/\/ \u8f93\u5165ctrl&#043;c\u6beb\u65e0\u53cd\u5e94<br \/>\nI am a process, I am waiting signal!<br \/>\n*\/<\/p>\n<\/p>\n<\/p>\n<\/p>\n<h2>2.\u4fe1\u53f7\u7684\u4ea7\u751f<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"142\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366730c7.png\" width=\"603\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"205\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-6899836681d38.png\" width=\"660\" \/><\/p>\n<\/p>\n<h3>2.1.\u8fdb\u7a0b\u7684\u7406\u89e3<\/h3>\n<\/p>\n<p>\u8981\u4e86\u89e3\u4fe1\u53f7\u7684\u4ea7\u751f&#xff0c;\u9996\u5148\u8981\u7406\u89e3\u8fdb\u7a0b\u7684\u79cd\u7c7b<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u5148\u8bf4\u7ed3\u8bba&#xff1a;\u8fdb\u7a0b\u5206\u6210\u4e24\u79cd<\/span><\/p>\n<p>1.\u524d\u53f0\u8fdb\u7a0b&#xff1a;# .\/xxx (\u5728\u542f\u52a8\u7cfb\u7edf\u7684\u65f6\u5019&#xff0c;\u4f1a\u9ed8\u8ba4\u5f00\u542f\u4e00\u4e2a\u8fdb\u7a0bshell\u8fdb\u7a0b&#xff0c;\u9ed8\u8ba4\u662f\u524d\u53f0\u8fdb\u7a0b)<\/p>\n<p>2.\u540e\u53f0\u8fdb\u7a0b&#xff1a;# .\/xxx &amp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"309\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-689983668fc75.png\" width=\"518\" \/><\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u8c08\u8c08\u8fd9\u4e24\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\u7684\u533a\u522b&#xff1a;<\/span><\/p>\n<\/p>\n<p>\u540e\u53f0\u8fdb\u7a0b\u65e0\u6cd5\u4ece\u6807\u51c6\u8f93\u5165&#xff08;\u952e\u76d8&#xff09;\u4e2d\u83b7\u53d6\u4fe1\u606f<\/p>\n<p>\u524d\u53f0\u8fdb\u7a0b\u53ef\u4ee5\u4ece\u6807\u51c6\u8f93\u5165&#xff08;\u952e\u76d8&#xff09;\u4e2d\u83b7\u53d6\u4fe1\u606f<\/p>\n<\/p>\n<p>\u4e3a\u4ec0\u4e48\u540e\u53f0\u8fdb\u7a0b\u4e0d\u53ef\u4ee5&#xff1f;<\/p>\n<p>\u952e\u76d8\u53ea\u6709\u4e00\u4e2a&#xff0c;\u8f93\u5165\u6570\u636e&#xff0c;\u4e00\u5b9a\u662f\u7ed9\u4e00\u4e2a\u786e\u5b9a\u7684\u8fdb\u7a0b&#xff0c;\u6240\u4ee5\u53ea\u80fd\u7ed9\u524d\u53f0\u8fdb\u7a0b\u53d1\u9001\u6d88\u606f&#xff0c;<\/p>\n<p>\u6240\u4ee5\u524d\u53f0\u8fdb\u7a0b\u53ea\u80fd\u6709\u4e00\u4e2a&#xff08;\u542f\u52a8shell\u7684\u65f6\u5019&#xff0c;bash\u8fdb\u7a0b\u9ed8\u8ba4\u4e3a\u524d\u53f0\u8fdb\u7a0b&#xff09;&#xff0c;\u540e\u53f0\u8fdb\u7a0b\u53ef\u4ee5\u6709\u591a\u4e2a&#xff0c;\u6240\u4ee5\u524d\u53f0\u8fdb\u7a0b\u7684\u672c\u8d28\u5c31\u662f\u5c31\u662f\u4ece\u4ece\u952e\u76d8\u4e2d\u83b7\u53d6\u6570\u636e\u3002<\/p>\n<\/p>\n<p>\u4f46\u662f\u90fd\u662f\u53ef\u4ee5\u5411\u6807\u51c6\u8f93\u51fa\u4e2d\u6253\u5370\u4fe1\u606f<\/p>\n<\/p>\n<p><span style=\"color:#ad720d\">\u89c2\u770b\u51e0\u4e2a\u73b0\u8c61&#xff1a;<\/span><\/p>\n<p>1.\u5f53.\/testing\u7684\u65f6\u5019&#xff0c;testing\u5c31\u662f\u524d\u53f0\u8fdb\u7a0b\u4e86&#xff0c;\u5c31\u628a\u539f\u6709\u7684bash\u8fdb\u7a0b\u7ed9\u6324\u4e0b\u53bb\u4e86&#xff0c;\u4f7f\u7528 \u547d\u4ee4\u884c ls \u7b49\u7b49\u7684&#xff0c;\u4e5f\u5c31\u5e76\u6ca1\u6709\u6548\u679c&#xff08;\u9a8c\u8bc1\u4e86\u524d\u53f0\u8fdb\u7a0b\u53ea\u80fd\u6709\u4e00\u4e2a\u7684\u7279\u6027&#xff09;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"171\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366a119c.png\" width=\"537\" \/><\/p>\n<\/p>\n<\/p>\n<p>2.\u5f53\u6267\u884c\u4ee5\u540e\u53f0\u8fdb\u7a0b\u8fdb\u7a0b\u8fdb\u884c\u6267\u884c\u7684\u65f6\u5019&#xff0c;\u6211\u8f93\u5165\u547d\u4ee4\u884c\u662f\u6709\u53cd\u5e94\u7684&#xff08;bash\u8fdb\u7a0b&#xff09;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"288\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366b04b3.png\" width=\"565\" \/><\/p>\n<\/p>\n<p>\u6b64\u65f6\u6211\u4eec\u60f3\u8981\u6740\u6389\u540e\u53f0\u8fdb\u7a0b\u7684\u548c\u5c31\u8981\u91cd\u65b0\u518d\u5f00\u542f\u4ee5Xshell&#xff0c;\u67e5\u8be2\u4ed6\u7684PID&#xff0c;\u5e76\u628a\u5b83\u7ed9\u6740\u6389<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"184\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366c04a7.png\" width=\"824\" \/><\/p>\n<\/p>\n<p>3.\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u7236\u8fdb\u7a0b\u5148\u9000\u51fa&#xff0c;\u5b50\u8fdb\u7a0bctrl&#043;c \u65e0\u6cd5\u9000\u51fa&#xff08;\u50f5\u5c38\u5b64\u513f&#xff09;&#xff0c;\u5c31\u662f\u5b50\u8fdb\u7a0b\u88ab\u81ea\u52a8\u63d0\u5230\u540e\u53f0\u8fdb\u7a0b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"165\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366d489e.png\" width=\"300\" \/><\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u8865\u5145\u4e00\u7ec4\u5173\u4e8e\u540e\u53f0\u548c\u524d\u53f0\u8fdb\u7a0b\u7684\u6307\u4ee4&#xff1a;<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u7b2c\u4e00\u7ec4&#xff1a;<\/span><\/p>\n<\/p>\n<p>jobs\u67e5\u770b\u6240\u6709\u7684\u540e\u53f0\u4efb\u52a1&#xff0c;\u53ef\u4ee5\u770b\u5230 \u5b83\u7684\u4efb\u52a1\u53f7\u4e3a1<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"169\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366de6ea.png\" width=\"661\" \/><br \/>\nfg \u4efb\u52a1\u53f7&#xff0c;\u7279\u5b9a\u7684\u8fdb\u7a0b&#xff0c;\u63d0\u5230\u524d\u53f0&#xff0c;ctrl&#043;c&#xff0c;\u6b64\u65f6\u5c31\u53ef\u4ee5\u6740\u6b7b\u8fdb\u7a0b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"203\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054510-68998366ec81a.png\" width=\"615\" \/><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u7b2c\u4e8c\u7ec4&#xff1a;<\/span><\/p>\n<\/p>\n<p>ctr&#043;z:\u8fdb\u7a0b\u5207\u6362\u5230\u540e\u53f0,\u4f7f\u7528jobs\u67e5\u770b\u540e\u53f0\u8fdb\u7a0b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"262\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-689983670a7dc.png\" width=\"695\" \/><\/p>\n<p>\nbg\u4efb\u52a1\u53f7:\u8ba9\u540e\u53f0\u8fdb\u884c\u56de\u590d\u8fd0\u884c&#xff0c;\u8ba9\u540e\u53f0\u8fdb\u7a0b\u7ee7\u7eed\u8fd0\u884c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"137\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-689983671bf13.png\" width=\"553\" \/><\/p>\n<\/p>\n<\/p>\n<p>\u4ec0\u4e48\u53eb\u505a\u8fdb\u7a0b\u53d1\u9001\u6d88\u606f?<\/p>\n<\/p>\n<p>\u4e4b\u524d\u7684\u4fe1\u53f7\u7684\u4e00\u4e2a\u7279\u6027&#xff1a;\u4fe1\u53f7\u7684\u5904\u7406&#xff0c;\u4e0d\u662f\u7acb\u5373\u5904\u7406&#xff0c;\u800c\u662f\u53ef\u4ee5\u7b49\u4e00\u4f1a\u5728\u5904\u7406&#xff0c;\u5408\u9002\u7684\u65f6\u5019&#xff0c;\u8fdb\u884c\u4fe1\u53f7\u7684\u5904\u7406<\/p>\n<\/p>\n<p>\u6240\u4ee5\u4fe1\u53f7\u4ea7\u751f\u4e4b\u540e&#xff0c;\u5e76\u4e0d\u662f\u7acb\u5373\u5904\u7406\u7684&#xff0c;\u6240\u4ee5\u8981\u6c42&#xff0c;\u8fdb\u7a0b\u5fc5\u987b\u628a\u4fe1\u53f7\u8bb0\u5f55\u4e0b\u6765<\/p>\n<\/p>\n<p>\u8bb0\u5f55\u5728\u54ea\u91cc&#xff1f;<\/p>\n<p>sigs&#xff1a;\u4e5f\u662f\u4e00\u4e2a\u4f4d\u56fe\u7684\u7ed3\u6784<\/p>\n<p>\u6bd4\u7279\u4f4d\u7684\u4f4d\u7f6e&#xff0c;\u4fe1\u53f7\u7f16\u53f7<\/p>\n<p>\u6bd4\u7279\u4f4d\u7684\u5185\u5bb9&#xff0c;\u662f\u5426\u6536\u5230<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"120\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-68998367273cf.png\" width=\"191\" \/><\/p>\n<\/p>\n<p>\u6240\u4ee5\u53d1\u9001\u4fe1\u53f7&#xff0c;\u672c\u8d28\u662f\u5411\u76ee\u6807\u8fdb\u7a0b\u5199\u4fe1\u53f7\u4fee\u6539\u4f4d\u56fe\u00a0 \u6839\u636epid,\u4fe1\u53f7\u7684\u7f16\u53f7<\/p>\n<\/p>\n<p>\u4f4d\u56fe\u5c5e\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u5185\u7684\u6570\u636e\u7ed3\u6784\u5bf9\u8c61 \u6240\u4ee5\u4fee\u6539\u4f4d\u56fe\u672c\u8d28:\u4fee\u6539\u5185\u6838\u7684\u6570\u636e<\/p>\n<p>\n\u4f46\u662f\u4fee\u6539\u5185\u6838\u6570\u636e\u53ea\u80fd\u662f\u64cd\u4f5c\u7cfb\u7edf\u81ea\u5df1&#xff0c;<\/p>\n<p>\u6240\u4ee5\u6700\u540e\u7684\u7ed3\u8bba&#xff1a;<span style=\"color:#fe2c24\">\u4e0d\u7ba1\u4fe1\u53f7\u600e\u4e48\u4ea7\u751f&#xff0c;\u53d1\u9001\u4fe1\u53f7&#xff0c;\u5728\u5e95\u5c42&#xff0c;\u5fc5\u987b\u8ba9\u7ed9os\u53d1\u9001<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u6240\u4ee5&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u5fc5\u987b\u63d0\u4f9b\u53d1\u9001\u4fe1\u53f7\u7684\u7cfb\u7edf\u8c03\u7528&#8211;kill<\/span><\/p>\n<\/p>\n<\/p>\n<h3>2.2.\u4fe1\u53f7\u4ea7\u751f\u7684\u65b9\u5f0f<\/h3>\n<\/p>\n<h4>2.2.1.\u901a\u8fc7\u952e\u76d8\u83b7\u53d6<\/h4>\n<p><span style=\"color:#1f2329\">Ctrl&#043;C (SIGINT) &#xff1a;\u7ec8\u6b62\u4e00\u4e2a\u8fdb\u7a0b<\/span><\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; &#034;&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f\u8fdb\u7a0b&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; std::endl;<br \/>\n    signal(SIGINT, SIG_DFL);  \/\/ \u8bbe\u7f6e\u4fe1\u53f7\u9ed8\u8ba4\u5904\u7406\u884c\u4e3a<br \/>\n    while(true){<br \/>\n        std::cout &lt;&lt; &#034;I am a process, I am waiting signal!&#034; &lt;&lt; std::endl;<\/p>\n<p>        sleep(1);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7&#xff1a;<br \/>\n\/*<br \/>\n$ g&#043;&#043; sig.cc -o sig<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;212791<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^C        \/\/ \u8f93\u5165Ctrl&#043;C&#xff0c;\u8fdb\u7a0b\u9000\u51fa&#xff08;SIGINT\u9ed8\u8ba4\u884c\u4e3a&#xff09;<br \/>\n*\/<\/p>\n<p><span style=\"color:#1456f0\">\u00a0<\/span><span style=\"color:#1f2329\">Ctrl&#043;\\\\&#xff08;SIGQUIT&#xff09;\u53ef\u4ee5\u53d1\u9001\u7ec8\u2f4c\u4fe1\u53f7\u5e76\u2f63\u6210core dump\u2f42\u4ef6&#xff0c;<\/span><\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; &#034;&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f\u8fdb\u7a0b&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; std::endl;<br \/>\n    signal(SIGQUIT, handler);  \/\/ SIGQUIT \u4fe1\u53f7\u7f16\u53f7\u901a\u5e38\u4e3a 3<br \/>\n    while(true){<br \/>\n        std::cout &lt;&lt; &#034;I am a process, I am waiting signal!&#034; &lt;&lt; std::endl;<br \/>\n        sleep(1);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7\u53ca\u6ce8\u91ca&#xff1a;<br \/>\n\/*<br \/>\n$ g&#043;&#043; sig.cc -o sig<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;213056<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^\\\\\u6211\u662f&#xff1a;213056&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;3  \/\/ \u6309\u4e0b Ctrl&#043;\\\\ \u89e6\u53d1 SIGQUIT&#xff0c;\u6267\u884c\u81ea\u5b9a\u4e49 handler<\/p>\n<p>\/\/ \u6ce8\u91ca\u6389\u7b2c13\u884c&#xff08;signal\u6ce8\u518c\u4ee3\u7801&#xff09;\u540e&#xff1a;<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;213146<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^\\\\Quit  \/\/ \u6309\u4e0b Ctrl&#043;\\\\ \u89e6\u53d1 SIGQUIT&#xff0c;\u6267\u884c\u9ed8\u8ba4\u884c\u4e3a&#xff08;\u7ec8\u6b62\u8fdb\u7a0b\u5e76\u751f\u6210 core&#xff09;<br \/>\n*\/<\/p>\n<p><span style=\"color:#1f2329\">Ctrl&#043;Z&#xff08;SIGTSTP&#xff09;\u53ef\u4ee5\u53d1\u9001\u505c\u2f4c\u4fe1\u53f7&#xff0c;\u5c06\u5f53\u524d\u524d\u53f0\u8fdb\u7a0b\u6302\u8d77\u5230\u540e\u53f0\u7b49\u3002<\/span><\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; &#034;&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;\u6211\u662f\u8fdb\u7a0b&#xff1a;&#034; &lt;&lt; getpid() &lt;&lt; std::endl;<br \/>\n    signal(SIGTSTP, handler);  \/\/ SIGTSTP \u4fe1\u53f7\u7f16\u53f7\u901a\u5e38\u4e3a 20&#xff08;\u7ec8\u7aef\u6682\u505c\u4fe1\u53f7&#xff0c;\u5982 Ctrl&#043;Z&#xff09;<br \/>\n    while(true){<br \/>\n        std::cout &lt;&lt; &#034;I am a process, I am waiting signal!&#034; &lt;&lt; std::endl;<br \/>\n        sleep(1);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7\u53ca\u6ce8\u91ca&#xff1a;<br \/>\n\/*<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;213552<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^Z\u6211\u662f&#xff1a;213552&#xff0c;\u6211\u83b7\u5f97\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;20  \/\/ \u6309\u4e0b Ctrl&#043;Z \u89e6\u53d1 SIGTSTP&#xff0c;\u6267\u884c\u81ea\u5b9a\u4e49 handler<\/p>\n<p>\/\/ \u6ce8\u91ca\u6389\u7b2c13\u884c&#xff08;signal\u6ce8\u518c\u4ee3\u7801&#xff09;\u540e&#xff1a;<br \/>\n$ .\/sig<br \/>\n\u6211\u662f\u8fdb\u7a0b&#xff1a;213627<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\nI am a process, I am waiting signal!<br \/>\n^Z<br \/>\n[1]&#043;  Stopped                 .\/sig  \/\/ \u89e6\u53d1 SIGTSTP \u9ed8\u8ba4\u884c\u4e3a&#xff08;\u6682\u505c\u8fdb\u7a0b&#xff09;<br \/>\nwhb&#064;bite:~\/code\/test$ jobs<br \/>\n[1]&#043;  Stopped                 .\/sig  \/\/ \u67e5\u770b\u6682\u505c\u7684\u8fdb\u7a0b<br \/>\n*\/<\/p>\n<\/p>\n<h4>2.2.2.\u8c03\u7528\u7cfb\u7edf\u547d\u4ee4\u5411\u8fdb\u7a0b\u53d1\u4fe1\u53f7<\/h4>\n<\/p>\n<p>sig\u4ee3\u7801&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"207\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-689983672fe02.png\" width=\"244\" \/><\/p>\n<\/p>\n<p>\u4ee5\u540e\u53f0\u8fdb\u7a0b\u8fdb\u884c\u8fd0\u884c&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"115\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-689983674407e.png\" width=\"570\" \/><\/p>\n<\/p>\n<p><span style=\"color:#646a73\">\u2fb8\u5148\u5728\u540e\u53f0\u6267\u2f8f\u6b7b\u5faa\u73af\u7a0b\u5e8f,\u7136\u540e\u2f64kill\u547d\u4ee4\u7ed9\u5b83\u53d1SIGSEGV\u4fe1\u53f7\u3002 <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"74\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-6899836759c7b.png\" width=\"317\" \/><\/p>\n<\/p>\n<\/p>\n<h4>2.2.3.\u7cfb\u7edf\u8c03\u7528&#xff08;\u51fd\u6570&#xff09;<\/h4>\n<\/p>\n<h5>2.2.3.1.kill<\/h5>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"225\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-689983676773a.png\" width=\"552\" \/><\/p>\n<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b&#xff1a;\u81ea\u5df1\u5904\u7406kill\u578b\u53f7<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>\/\/ .\/mykill signumber pid<br \/>\nint main(int argc, char *argv[])<br \/>\n{<br \/>\n    if(argc !&#061; 3)<br \/>\n    {<br \/>\n        std::cout &lt;&lt; &#034;.\/mykill signumber pid&#034; &lt;&lt; std::endl;<br \/>\n        return 1;<br \/>\n    }<br \/>\n    int signum &#061; std::stoi(argv[1]);\/\/stoi:\u5c06\u5b57\u7b26\u4e32\u8f6c\u6210\u6574\u6570<br \/>\n    pid_t target &#061; std::stoi(argv[2]);<\/p>\n<p>    int n &#061; kill(target, signum);<br \/>\n    if(n &#061;&#061; 0)<br \/>\n    {<br \/>\n        std::cout &lt;&lt; &#034;send &#034; &lt;&lt; signum &lt;&lt; &#034; to &#034; &lt;&lt; target &lt;&lt; &#034; success.&#034;;<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<\/p>\n<h5>2.2.3.2.raise<\/h5>\n<p><span style=\"color:#646a73\">raise <\/span><span style=\"color:#646a73\">\u51fd\u6570\u53ef\u4ee5\u7ed9\u5f53\u524d\u8fdb\u7a0b\u53d1\u9001\u6307\u5b9a\u7684\u4fe1\u53f7(\u2f83\u2f30\u7ed9\u2f83\u2f30\u53d1\u4fe1\u53f7)\u3002 <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"251\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054511-68998367760f3.png\" width=\"692\" \/><\/p>\n<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b&#xff1a;\u81ea\u5df1\u7ed9\u81ea\u5df1\u53d1\u9001\u578b\u53f7&#xff0c;\u5e76\u81ea\u5b9a\u4e49\u5904\u7406<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    \/\/ \u6574\u4e2a\u4ee3\u7801\u5c31\u53ea\u6709\u8fd9\u4e00\u5904\u6253\u5370<br \/>\n    std::cout &lt;&lt; &#034;\u83b7\u53d6\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>\/\/ mykill -signumber pid<br \/>\nint main()<br \/>\n{<br \/>\n    signal(2, handler);  \/\/ \u5148\u5bf92\u53f7\u4fe1\u53f7\u8fdb\u884c\u6355\u6349<br \/>\n    \/\/ \u6bcf\u96941S&#xff0c;\u81ea\u5df1\u7ed9\u81ea\u5df1\u53d1\u90012\u53f7\u4fe1\u53f7<br \/>\n    while(true)<br \/>\n    {<br \/>\n        sleep(1);<br \/>\n        raise(2);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7&#xff1a;<br \/>\n\/*<br \/>\n$ g&#043;&#043; raise.cc -o raise<br \/>\n$ .\/raise<br \/>\n\u83b7\u53d6\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;2<br \/>\n\u83b7\u53d6\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;2<br \/>\n\u83b7\u53d6\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;2<br \/>\n*\/<\/p>\n<\/p>\n<h5>2.2.3.3.abort<\/h5>\n<\/p>\n<p><span style=\"color:#646a73\">abort <\/span><span style=\"color:#646a73\">\u51fd\u6570\u4f7f\u5f53\u524d\u8fdb\u7a0b\u63a5\u6536\u5230\u4fe1\u53f7\u2f7d\u5f02\u5e38\u7ec8\u2f4c\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"200\" src=\"2025-08-11ibwy0iikt4e.png\" width=\"534\" \/><\/p>\n<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>\u5176\u5b9e\u4e5f\u662f\u81ea\u5df1\u7ed9\u81ea\u5df1\u53d1\u4fe1\u53f7&#xff0c;\u4f46\u662f\u6b64\u65f6\u662f\u53d1\u4e00\u4e2a\u56fa\u5b9a\u7684\u4fe1\u53f7&#xff0c;6&#xff0c;\u7528\u4e8e\u7ec8\u6b62<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int signumber)<br \/>\n{<br \/>\n    \/\/ \u6574\u4e2a\u4ee3\u7801\u5c31\u53ea\u6709\u8fd9\u4e00\u5904\u6253\u5370<br \/>\n    std::cout &lt;&lt; &#034;\u83b7\u53d6\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;&#034; &lt;&lt; signumber &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>\/\/ mykill -signumber pid<br \/>\nint main()<br \/>\n{<br \/>\n    signal(SIGABRT, handler);<br \/>\n    while(true)<br \/>\n    {<br \/>\n        sleep(1);<br \/>\n        abort();<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u7f16\u8bd1\u8fd0\u884c\u65e5\u5fd7&#xff1a;<br \/>\n\/*<br \/>\n$ g&#043;&#043; Abort.cc -o Abort<br \/>\n$ .\/Abort<br \/>\n\u83b7\u53d6\u4e86\u4e00\u4e2a\u4fe1\u53f7&#xff1a;6  \/\/ \u5b9e\u9a8c\u53ef\u4ee5\u5f97\u77e5, abort\u7ed9\u81ea\u5df1\u53d1\u9001\u7684\u662f\u56fa\u5b9a6\u53f7\u4fe1\u53f7, \u867d\u7136\u6355\u6349\u4e86, \u4f46\u662f\u8fd8\u662f\u8981\u9000\u51fa<br \/>\nAborted<\/p>\n<p>\/\/ \u6ce8\u91ca\u6389\u7b2c15\u884c&#xff08;signal\u6ce8\u518c\u4ee3\u7801&#xff09;\u540e&#xff1a;<br \/>\n$ .\/Abort<br \/>\nAborted<br \/>\n*\/<\/p>\n<\/p>\n<h4>2.2.4.\u786c\u4ef6\u5f02\u5e38\u4ea7\u751f\u4fe1\u53f7<\/h4>\n<\/p>\n<p>\u786c\u4ef6\u5f02\u5e38\u88ab\u786c\u4ef6\u4ee5\u67d0\u79cd\u65b9\u5f0f\u88ab\u786c\u4ef6\u68c0\u6d4b\u5230\u5e76\u901a\u77e5\u5185\u6838,\u7136\u540e\u5185\u6838\u5411\u5f53\u524d\u8fdb\u7a0b\u53d1\u9001\u9002\u5f53\u7684\u4fe1\u53f7\u3002<\/p>\n<p>\u4f8b\u5982\u5f53\u524d\u8fdb\u7a0b\u6267\u884c\u4e86\u9664\u4ee50\u7684\u6307\u4ee4,CPU\u7684\u8fd0\u7b97\u5355\u5143\u4f1a\u4ea7\u751f\u5f02\u5e38,\u5185\u6838\u5c06\u8fd9\u4e2a\u5f02\u5e38\u89e3\u91ca\u4e3aSIGFPE\u4fe1\u53f7\u53d1\u9001\u7ed9\u8fdb\u7a0b\u3002<\/p>\n<p>\u518d\u6bd4\u5982\u5f53\u524d\u8fdb\u7a0b\u8bbf\u95ee\u4e86\u975e\u6cd5\u5185\u5b58\u5730\u5740,MMU\u4f1a\u4ea7\u751f\u5f02\u5e38,\u5185\u6838\u5c06\u8fd9\u4e2a\u5f02\u5e38\u89e3\u91ca\u4e3aSIGSEGV\u4fe1\u53f7\u53d1\u9001\u7ed9\u8fdb\u7a0b\u3002<\/p>\n<\/p>\n<p>1.\u96640\u64cd\u4f5c<\/p>\n<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int sig)<br \/>\n{<br \/>\n    printf(&#034;catch a sig : %d\\\\n&#034;, sig);<br \/>\n}<\/p>\n<p>\/\/ vi<br \/>\nint main()<br \/>\n{<br \/>\n    \/\/signal(SIGFPE, handler); \/\/ 8) SIGFPE&#xff08;\u7b97\u672f\u5f02\u5e38\u4fe1\u53f7&#xff0c;\u5982\u9664\u96f6\u9519\u8bef&#xff09;<br \/>\n    sleep(1);<br \/>\n    int a &#061; 10;<br \/>\n    a \/&#061; 0;  \/\/ \u89e6\u53d1\u9664\u96f6\u9519\u8bef&#xff0c;\u4ea7\u751f SIGFPE \u4fe1\u53f7<br \/>\n    while(1);<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; \u8fd0\u884c\u65e5\u5fd7 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\/\/ \u60c5\u51b51&#xff1a;\u4e0d\u6ce8\u91ca\u7b2c11\u884c&#xff08;\u6ce8\u518c\u4fe1\u53f7\u5904\u7406\u51fd\u6570&#xff09;&#xff1a;<br \/>\n\/\/ $ gcc sigfpe.c -o sigfpe<br \/>\n\/\/ $ .\/sigfpe<br \/>\n\/\/ catch a sig : 8        # handler \u6355\u83b7\u5230 SIGFPE&#xff08;\u7f16\u53f78&#xff09;<br \/>\n\/\/ Floating point exception (core dumped)  # \u7cfb\u7edf\u4ecd\u7ec8\u6b62\u8fdb\u7a0b&#xff08;\u7b97\u672f\u5f02\u5e38\u4e3a\u81f4\u547d\u9519\u8bef&#xff09;<\/p>\n<p>\/\/ \u60c5\u51b52&#xff1a;\u6ce8\u91ca\u7b2c11\u884c&#xff08;\u672a\u6ce8\u518c\u5904\u7406\u51fd\u6570&#xff09;&#xff1a;<br \/>\n\/\/ $ gcc sigfpe.c -o sigfpe<br \/>\n\/\/ $ .\/sigfpe<br \/>\n\/\/ Floating point exception (core dumped)  # \u76f4\u63a5\u5d29\u6e83&#xff0c;\u65e0 handler \u8f93\u51fa<\/p>\n<p>2.\u91ce\u6307\u9488\u975e\u6cd5\u8bbf\u95ee<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int sig)<br \/>\n{<br \/>\n    printf(&#034;catch a sig : %d\\\\n&#034;, sig);<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/signal(SIGSEGV, handler);  \/\/ SIGSEGV&#xff1a;\u6bb5\u9519\u8bef\u4fe1\u53f7&#xff08;\u7f16\u53f711&#xff0c;\u5982\u89e3\u5f15\u7528\u7a7a\u6307\u9488&#xff09;<br \/>\n    sleep(1);<br \/>\n    int *p &#061; NULL;<br \/>\n    *p &#061; 100;  \/\/ \u89e3\u5f15\u7528\u7a7a\u6307\u9488&#xff0c;\u89e6\u53d1 SIGSEGV<br \/>\n    while(1);<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; \u8fd0\u884c\u65e5\u5fd7 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\/\/ \u60c5\u51b51&#xff1a;\u6ce8\u91ca\u7b2c37\u884c&#xff08;\u672a\u6ce8\u518c\u4fe1\u53f7\u5904\u7406\u51fd\u6570&#xff09;&#xff1a;<br \/>\n\/\/ $ gcc sigsegv.c -o sigsegv<br \/>\n\/\/ $ .\/sigsegv<br \/>\n\/\/ Segmentation fault (core dumped)  # \u76f4\u63a5\u5d29\u6e83&#xff0c;\u65e0 handler \u8f93\u51fa<\/p>\n<p>\/\/ \u60c5\u51b52&#xff1a;\u4e0d\u6ce8\u91ca\u7b2c37\u884c&#xff08;\u6ce8\u518c handler&#xff09;&#xff1a;<br \/>\n\/\/ $ gcc sigsegv.c -o sigsegv<br \/>\n\/\/ $ .\/sigsegv<br \/>\n\/\/ catch a sig : 11        # handler \u6355\u83b7\u5230 SIGSEGV&#xff08;\u7f16\u53f711&#xff09;<br \/>\n\/\/ Segmentation fault (core dumped)  # \u4ecd\u5d29\u6e83&#xff08;\u6bb5\u9519\u8bef\u4e3a\u81f4\u547d\u5f02\u5e38&#xff09;<\/p>\n<\/p>\n<h4>2.2.5.\u8f6f\u4ef6\u6761\u4ef6\u4ea7\u751f\u4fe1\u53f7<\/h4>\n<\/p>\n<p>\u6b64\u65f6\u7ee7\u7eed\u4ecb\u7ecd\u4e00\u4e2a\u51fd\u6570&#8212; \u300b\u300balarm\u95f9\u949f\u548c<span style=\"color:#1f2329\">\u00a0<\/span><span style=\"color:#1f2329\">SIGALRM <\/span><span style=\"color:#1f2329\">\u4fe1\u53f7\u3002 <\/span><\/p>\n<\/p>\n<p><span style=\"color:#1f2329\">\u8c03\u2f64 <\/span><span style=\"color:#1f2329\">alarm <\/span><span style=\"color:#1f2329\">\u51fd\u6570\u53ef\u4ee5\u8bbe\u5b9a\u2f00\u4e2a\u95f9\u949f,\u4e5f\u5c31\u662f\u544a\u8bc9\u5185\u6838\u5728 <\/span><span style=\"color:#1f2329\">seconds <\/span><span style=\"color:#1f2329\">\u79d2\u4e4b\u540e\u7ed9\u5f53\u524d\u8fdb\u7a0b\u53d1 SIGALRM \u4fe1\u53f7&#xff0c;\u8be5\u4fe1\u53f7\u7684\u9ed8\u8ba4\u5904\u7406\u52a8\u4f5c\u662f\u7ec8\u2f4c\u5f53\u524d\u8fdb\u7a0b\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"339\" src=\"2025-08-11kqrx2qbgr1y.png\" width=\"972\" \/><\/p>\n<\/p>\n<\/p>\n<\/p>\n<h5>2.2.5.1.\u4f7f\u7528alarm\u51fd\u6570\u9a8c\u8bc1io\u7684\u901f\u5ea6<\/h5>\n<\/p>\n<p>1. IO \u5bc6\u96c6\u578b\u4ee3\u7801<\/p>\n<p>\/\/ IO \u591a<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    int count &#061; 0;<br \/>\n    while(true)<br \/>\n    {<br \/>\n        std::cout &lt;&lt; &#034;count : &#034; &lt;&lt; count &lt;&lt; std::endl;<br \/>\n        count&#043;&#043;;<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<br \/>\n&#8230; &#8230;<br \/>\ncount : 107148<br \/>\ncount : 107149<br \/>\nAlarm clock  \/\/ \u957f\u65f6\u95f4\u672a\u9000\u51fa&#xff0c;\u7cfb\u7edf\u53ef\u80fd\u56e0\u7ec8\u7aef\u7f13\u51b2\u6216\u8d85\u65f6\u5f3a\u5236\u7ec8\u6b62&#xff08;\u6216\u89e6\u53d1\u9ed8\u8ba4\u95f9\u949f\u4fe1\u53f7&#xff09;<\/p>\n<\/p>\n<p>2. CPU \u5bc6\u96c6\u578b &#043; \u4fe1\u53f7\u793a\u4f8b<\/p>\n<p>\/\/ IO \u5c11<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>int count &#061; 0;<br \/>\nvoid handler(int signumber)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;count : &#034; &lt;&lt; count &lt;&lt; std::endl;<br \/>\n    exit(0);<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    signal(SIGALRM, handler);<br \/>\n    alarm(1);  \/\/ 1\u79d2\u540e\u89e6\u53d1 SIGALRM \u4fe1\u53f7<br \/>\n    while (true)<br \/>\n    {<br \/>\n        count&#043;&#043;;  \/\/ \u7eaf\u8ba1\u7b97&#xff0c;\u65e0IO<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<br \/>\n$ g&#043;&#043; alarm.cc -o alarm<br \/>\nwhb&#064;bite:~\/code\/test$ .\/alarm<br \/>\ncount : 49233713  # 1\u79d2\u5185\u7eaf\u8ba1\u7b97\u7684\u5faa\u73af\u6b21\u6570&#xff08;\u8fdc\u9ad8\u4e8eIO\u5bc6\u96c6\u578b&#xff0c;\u4f53\u73b0IO\u8017\u65f6\u5f71\u54cd&#xff09;<\/p>\n<\/p>\n<\/p>\n<h2>3.\u4fdd\u5b58\u4fe1\u53f7<\/h2>\n<p>\u00a0\u5f53\u524d\u9636\u6bb5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"213\" src=\"2025-08-11uf0tv0jqrnx.png\" width=\"959\" \/><\/p>\n<\/p>\n<h3>3.1.\u6982\u5ff5\u94fa\u57ab<\/h3>\n<p>\n\u00a0<\/p>\n<\/p>\n<p>\u4fdd\u5b58\u4fe1\u53f7\u4e2d\u7684\u76f8\u5173\u7684\u6982\u5ff5&#xff1a;<\/p>\n<\/p>\n<p>1.\u5b9e\u9645\u6267\u884c\u4fe1\u53f7\u7684\u5904\u7406\u52a8\u4f5c\u79f0\u4e3a\u4fe1\u53f7\u9012\u8fbe(Delivery)<br \/>\n2.\u4fe1\u53f7\u4ece\u4ea7\u751f\u5230\u9012\u8fbe\u4e4b\u95f4\u7684\u72b6\u6001,\u79f0\u4e3a\u4fe1\u53f7\u672a\u51b3(Pending)\u3002<br \/>\n3.\u8fdb\u7a0b\u53ef\u4ee5\u9009\u62e9\u963b\u585e(Block)\u67d0\u4e2a\u4fe1\u53f7\u3002\u88ab\u963b\u585e\u7684\u4fe1\u53f7\u4ea7\u751f\u65f6\u5c06\u4fdd\u6301\u5728\u672a\u51b3\u72b6\u6001,\u76f4\u5230\u8fdb\u7a0b\u89e3\u9664\u5bf9\u6b64\u4fe1\u53f7\u7684\u963b\u585e,\u624d\u6267\u884c\u9012\u8fbe\u7684\u52a8\u4f5c\u3002<\/p>\n<p><span style=\"color:#fe2c24\">\u6ce8\u610f,\u963b\u585e\u548c\u5ffd\u7565\u662f\u4e0d\u540c\u7684,\u53ea\u8981\u4fe1\u53f7\u88ab\u963b\u585e\u5c31\u4e0d\u4f1a\u9012\u8fbe,\u800c\u5ffd\u7565\u662f\u5728\u9012\u8fbe\u4e4b\u540e\u53ef\u9009\u7684\u4e00\u79cd\u5904\u7406\u52a8\u4f5c\u3002<\/span><\/p>\n<\/p>\n<\/p>\n<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u8981\u4e86\u89e3\u8fd9\u4e09\u5f20\u8868&#xff1a;\u4fdd\u5b58\u4fe1\u53f7\u5c31\u662f\u4f9d\u9760\u8fd9\u4e09\u5f20\u8868\u7ed3\u6784<\/p>\n<\/p>\n<p><span style=\"color:#1a439c\">\u524d\u63d0&#xff1a;\u8fd9\u4e09\u5f20\u8868\u90fd\u662f\u65e0\u7b26\u53f7\u6574\u6570&#xff08;unsigned int &#xff09;&#xff0c;\u4f4d\u56fe\u7684\u7ed3\u6784<\/span><\/p>\n<\/p>\n<p><span style=\"color:#ad720d\">block\u8868&#xff1a;<\/span><\/p>\n<p>\u6bd4\u7279\u4f4d\u7684\u4f4d\u7f6e:\u8868\u793a\u7684\u662f\u7b2c\u51e0\u4e2a\u4fe1\u53f7<\/p>\n<p>\u6bd4\u7279\u4f4d\u7684\u5185\u5bb9:\u662f\u5426\u963b\u585e!<\/p>\n<\/p>\n<p><span style=\"color:#ad720d\">penging\u8868&#xff1a;<\/span><\/p>\n<p>\u6bd4\u7279\u4f4d\u7684\u4f4d\u7f6e:\u8868\u793a\u7684\u662f\u7b2c\u51e0\u4e2a\u4fe1\u53f7<\/p>\n<p>\u6bd4\u7279\u4f4d\u7684\u5185\u5bb9:\u662f\u5426\u6536\u5230!<\/p>\n<\/p>\n<p><span style=\"color:#ad720d\">handler\u8868&#xff1a;\u91cc\u9762\u5b58\u50a8\u7684\u662f\u51fd\u6570\u6307\u9488<\/span><\/p>\n<p>\u6570\u7ec4\u4e0b\u6807&#xff1a;\u4fe1\u53f7\u7f16\u53f7<\/p>\n<p>SIG_DEL&#xff1a;\u9ed8\u8ba4<\/p>\n<p>SIG_IGN:\u5ffd\u7565<\/p>\n<p>&#xff08;\u6240\u4ee5\u4e4b\u524d\u6211\u4eec\u6355\u6349\u4fe1\u53f7&#xff0c;\u5e76\u5bf9\u4fe1\u53f7\u8fdb\u884c\u81ea\u5b9a\u4e49\u5904\u7406&#xff0c;\u5176\u5b9e\u5c31\u662f\u6539\u53d8handler\u5bf9\u5e94\u4e0b\u6807\u91cc\u9762\u7684\u64cd\u4f5c\u662f \u5ffd\u7565 or \u9ed8\u8ba4 or \u81ea\u5b9a\u4e49&#xff09;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"398\" src=\"2025-08-11ekvd34xwxzj.png\" width=\"1135\" \/><\/p>\n<\/p>\n<p><span style=\"color:#a2e043\">\u6240\u4ee5\u5904\u7406\u4e00\u4e2a\u4fe1\u53f7\u662f\u770b\u4e09\u5f20\u8868\u7684\u540c\u4e0b\u6807\u4f4d\u7f6e&#xff0c;<\/span><\/p>\n<p><span style=\"color:#a2e043\">\u5148\u770bpending\u8868&#xff1a;\u770b\u4fe1\u53f7\u662f\u5426\u6536\u5230&#xff0c;\u5982\u679c\u6536\u5230<\/span><\/p>\n<p><span style=\"color:#a2e043\">\u518d\u770bblock\u8868&#xff1a;\u770b\u4fe1\u53f7\u662f\u5426\u5148\u5b58\u653e\u7740\u8fd8\u662f\u6267\u884c&#xff0c;\u5982\u679c\u4e0d\u963b\u585e<\/span><\/p>\n<p><span style=\"color:#a2e043\">\u6700\u540e\u770bhandler\u8868&#xff1a;\u662f\u5982\u4f55\u6267\u884c\u8be5\u4fe1\u53f7<\/span><\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"257\" src=\"2025-08-11vdqtfjqhhfp.png\" width=\"633\" \/><\/p>\n<\/p>\n<\/p>\n<p>sigser_t:<\/p>\n<\/p>\n<h3>3.2.\u4fe1\u53f7\u96c6\u64cd\u4f5c\u51fd\u6570<\/h3>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u60f3\u8981\u4f7f\u7528\u4fe1\u53f7\u96c6\u64cd\u4f5c\u51fd\u6570&#xff0c;\u6240\u4ee5\u8981\u5148\u4e86\u89e3\u4e00\u4e0b\u4fe1\u53f7\u96c6&#xff08;signal_t&#xff09;\u7684\u6982\u5ff5&#xff1a;<\/span><\/p>\n<p>\u4ece\u4e0a\u56fe\u6765\u770b,\u6bcf\u4e2a\u4fe1\u53f7\u53ea\u6709\u4e00\u4e2abit\u7684\u672a\u51b3\u6807\u5fd7,\u975e0\u53731,\u4e0d\u8bb0\u5f55\u8be5\u4fe1\u53f7\u4ea7\u751f\u4e86\u591a\u5c11\u6b21,\u963b\u585e\u6807\u5fd7\u4e5f\u662f\u8fd9\u6837\u8868\u793a\u7684\u3002\u56e0\u6b64,\u672a\u51b3\u548c\u963b\u585e\u6807\u5fd7\u53ef\u4ee5\u7528\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578bsigset_t\u6765\u5b58\u50a8,sigpet_t\u79f0\u4e3a\u4fe1\u53f7\u96c6,<\/p>\n<p>\u8fd9\u4e2a\u7c7b\u578b\u53ef\u4ee5\u8868\u793a\u6bcf\u4e2a\u4fe1\u53f7\u7684\u201c\u6709\u6548\u201d\u6216\u201c\u65e0\u6548\u201d\u72b6\u6001,\u5728\u963b\u585e\u4fe1\u53f7\u96c6\u4e2d\u201c\u6709\u6548\u201d\u548c\u201c\u65e0\u6548\u201d\u7684\u542b\u4e49\u662f\u8be5\u4fe1\u53f7\u662f\u5426\u88ab\u963b\u585e,\u800c\u5728\u672a\u51b3\u4fe1\u53f7\u96c6\u4e2d\u201c\u6709 \u6548\u201d\u548c\u201c\u65e0\u6548\u201d\u7684\u542b\u4e49\u662f\u8be5\u4fe1\u53f7\u662f\u5426\u5904\u4e8e\u672a\u51b3\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"223\" src=\"2025-08-11cmd5kwjlqcr.png\" width=\"683\" \/><\/p>\n<p>1.sigemptyset<\/p>\n<p>\u529f\u80fd&#xff1a;\u521d\u59cb\u5316\u4fe1\u53f7\u96c6&#xff0c;\u4f7f\u5176\u4e3a\u7a7a&#xff08;\u4e0d\u5305\u542b\u4efb\u4f55\u4fe1\u53f7&#xff09;\u3002<br \/>\n\u53c2\u6570&#xff1a;set \u6307\u5411\u8981\u521d\u59cb\u5316\u7684 sigset_t \u53d8\u91cf\u3002<br \/>\n\u8fd4\u56de&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de &#8211; 1&#xff08;\u5e76\u8bbe\u7f6e errno&#xff09;\u3002<br \/>\n\u6ce8\u610f&#xff1a;\u4f7f\u7528\u4fe1\u53f7\u96c6\u524d\u5fc5\u987b\u5148\u521d\u59cb\u5316&#xff0c;\u5426\u5219\u5185\u5bb9\u4e0d\u786e\u5b9a\u3002<\/p>\n<p>2.sigfillset<\/p>\n<p>\u529f\u80fd&#xff1a;\u521d\u59cb\u5316\u4fe1\u53f7\u96c6&#xff0c;\u4f7f\u5176\u5305\u542b\u6240\u6709\u5df2\u5b9a\u4e49\u7684\u4fe1\u53f7&#xff08;\u5982 SIGINT\u3001SIGTERM \u7b49&#xff0c;\u5177\u4f53\u53d6\u51b3\u4e8e\u7cfb\u7edf&#xff09;\u3002<br \/>\n\u53c2\u6570&#xff1a;set \u6307\u5411\u8981\u521d\u59cb\u5316\u7684 sigset_t \u53d8\u91cf\u3002<br \/>\n\u8fd4\u56de&#xff1a;\u6210\u529f\u8fd4\u56de 0&#xff0c;\u5931\u8d25\u8fd4\u56de &#8211; 1\u3002<br \/>\n\u573a\u666f&#xff1a;\u9700\u8981\u963b\u585e\u6240\u6709\u4fe1\u53f7\u65f6&#xff0c;\u5148 fill \u518d\u8c03\u6574\u3002<\/p>\n<p>3.sigaddset<\/p>\n<p>\u529f\u80fd&#xff1a;\u5411\u4fe1\u53f7\u96c6\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u4fe1\u53f7&#xff08;signo \u6307\u5b9a\u7684\u4fe1\u53f7\u52a0\u5165\u96c6\u5408&#xff09;\u3002<br \/>\n\u53c2\u6570&#xff1a;set \u662f\u76ee\u6807\u96c6\u5408&#xff0c;signo \u662f\u4fe1\u53f7\u7f16\u53f7&#xff08;\u5982 SIGUSR1&#xff09;\u3002<br \/>\n\u8fd4\u56de&#xff1a;\u6210\u529f 0&#xff0c;\u5931\u8d25 &#8211; 1\u3002<br \/>\n\u6ce8\u610f&#xff1a;\u6dfb\u52a0\u524d\u96c6\u5408\u9700\u5df2\u521d\u59cb\u5316&#xff08;\u5982\u7528 sigemptyset \u6216 sigfillset&#xff09;\u3002<\/p>\n<p>4.sigdelset<\/p>\n<p>\u529f\u80fd&#xff1a;\u4ece\u4fe1\u53f7\u96c6\u4e2d\u5220\u9664\u4e00\u4e2a\u4fe1\u53f7&#xff08;\u79fb\u9664 signo \u6307\u5b9a\u7684\u4fe1\u53f7&#xff09;\u3002<br \/>\n\u53c2\u6570&#xff1a;set \u662f\u76ee\u6807\u96c6\u5408&#xff0c;signo \u662f\u4fe1\u53f7\u7f16\u53f7\u3002<br \/>\n\u8fd4\u56de&#xff1a;\u6210\u529f 0&#xff0c;\u5931\u8d25 &#8211; 1\u3002<br \/>\n\u573a\u666f&#xff1a;\u6bd4\u5982\u5148 fill \u6240\u6709\u4fe1\u53f7&#xff0c;\u518d del \u6389\u4e0d\u60f3\u963b\u585e\u7684\u4fe1\u53f7\u3002<\/p>\n<p>5.sigismember<\/p>\n<p>\u529f\u80fd&#xff1a;\u68c0\u67e5\u4fe1\u53f7\u662f\u5426\u5728\u96c6\u5408\u4e2d\u3002<br \/>\n\u53c2\u6570&#xff1a;set \u662f\u4fe1\u53f7\u96c6&#xff0c;signo \u662f\u8981\u68c0\u67e5\u7684\u4fe1\u53f7\u3002<br \/>\n\u8fd4\u56de&#xff1a;<br \/>\n1&#xff1a;\u4fe1\u53f7\u5728\u96c6\u5408\u4e2d&#xff1b;<br \/>\n0&#xff1a;\u4fe1\u53f7\u4e0d\u5728\u96c6\u5408\u4e2d&#xff1b;<br \/>\n-1&#xff1a;\u51fa\u9519&#xff08;\u5982 signo \u65e0\u6548&#xff09;\u3002<br \/>\n\u7528\u9014&#xff1a;\u5224\u65ad\u67d0\u4e2a\u4fe1\u53f7\u662f\u5426\u88ab\u5305\u542b&#xff0c;\u5e38\u7528\u4e8e\u8c03\u8bd5\u6216\u903b\u8f91\u5224\u65ad\u3002<\/p>\n<\/p>\n<p>3.2.1.sigprocmask<\/p>\n<p>\u7528\u4e8e\u00a0\u4fee\u6539\u8fdb\u7a0b\u7684\u4fe1\u53f7\u5c4f\u853d\u5b57&#xff08;\u963b\u585e\u4fe1\u53f7\u96c6&#xff09;&#xff0c;\u51b3\u5b9a\u54ea\u4e9b\u4fe1\u53f7\u4f1a\u88ab \u201c\u62e6\u622a\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-11ckjpjfpssfn.png\" width=\"578\" \/><\/p>\n<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>how&#xff1a;\u6307\u5b9a\u4fee\u6539\u5c4f\u853d\u5b57\u7684\u65b9\u5f0f&#xff08;3 \u79cd\u53ef\u9009&#xff0c;\u89c1\u4e0b\u8868&#xff09;\u3002<\/li>\n<li>set&#xff1a;\u6307\u5411\u8981\u64cd\u4f5c\u7684\u4fe1\u53f7\u96c6&#xff08;NULL\u00a0\u8868\u793a \u201c\u4e0d\u4fee\u6539\u5c4f\u853d\u5b57\u201d&#xff0c;\u4ec5\u5907\u4efd\u65e7\u503c&#xff09;\u3002<\/li>\n<li>oset&#xff1a;\u8f93\u51fa\u53c2\u6570&#xff0c;\u7528\u4e8e\u4fdd\u5b58\u65e7\u7684\u5c4f\u853d\u5b57&#xff08;NULL\u00a0\u8868\u793a \u201c\u4e0d\u4fdd\u5b58\u201d&#xff09;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"237\" src=\"2025-08-11qipl2vm4l30.png\" width=\"864\" \/><\/li>\n<\/ul>\n<p>3.2.2.sigpending<\/p>\n<p>\u7528\u4e8e\u00a0\u83b7\u53d6\u5f53\u524d\u8fdb\u7a0b\u7684\u672a\u51b3\u4fe1\u53f7\u96c6<\/p>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"69\" src=\"2025-08-113moav3l0p2h.png\" width=\"427\" \/><\/p>\n<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>set&#xff1a;\u8f93\u51fa\u53c2\u6570&#xff0c;\u5b58\u50a8\u672a\u51b3\u4fe1\u53f7\u96c6&#xff08;\u88ab\u5c4f\u853d\u4f46\u5df2\u5230\u8fbe\u7684\u4fe1\u53f7&#xff09;\u3002<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de\u00a00&#xff0c;\u5931\u8d25\u8fd4\u56de\u00a0-1&#xff08;\u9700\u68c0\u67e5\u00a0errno&#xff09;\u3002<\/li>\n<\/ul>\n<\/p>\n<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>\u4e24\u4e2a\u7279\u6027&#xff1a;<\/p>\n<p>1.9\u53f7\u4fe1\u53f7&#xff0c;\u4e0d\u53ef\u88ab\u6355\u6349&#xff0c;\u4e0d\u53ef\u88ab\u963b\u585e<\/p>\n<p>2.\u5f53\u6211\u4eec\u51c6\u5907\u9012\u8fbe\u7684\u65f6\u5019&#xff0c;\u8981\u9996\u5148\u6e05\u7a7apending\u4fe1\u53f7\u96c6\u4e2d\u5bf9\u5e94\u7684\u4fe1\u53f7\u4f4d\u56fe 1-&gt;0<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>using namespace std;<\/p>\n<p>void Pint(sigset_t &amp;pending)<br \/>\n{<br \/>\n    for(int i&#061;31;i&gt;&#061;1;i&#8211;){<br \/>\n        if(sigismember(&amp;pending,)i){<br \/>\n            cout&lt;&lt;&#034;1&#034;&lt;&lt;;<br \/>\n        }else{<br \/>\n            cout&lt;&lt;&#034;0&#034;&lt;&lt;;<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>int main(){<\/p>\n<p>    \/\/1.\u5c4f\u853d2\u53f7\u4fe1\u53f7<br \/>\n    sigset_t block, oldset;<br \/>\n    \/\/\u521d\u59cb\u5316<br \/>\n    sigmptyset(&amp;block);<br \/>\n    sigmptyset(&amp;oldset);<\/p>\n<p>    \/\/\u8bbe\u7f6e2\u53f7\u4fe1\u53f7<br \/>\n    sigaddset(&amp;block,2);<br \/>\n    int n&#061;sigprocmask(SIG_SETMASK,&amp;block,&amp;oldset);<\/p>\n<p>    \/\/2.\u83b7\u53d6pending\u4fe1\u53f7<br \/>\n    sigset_t pending;<br \/>\n    int m&#061;sigpending(&amp;pending);<\/p>\n<p>    \/\/3.\u6253\u5370pending\u4fe1\u53f7<br \/>\n    Pint(pending);<br \/>\n}<\/p>\n<\/p>\n<\/p>\n<p>\u5728\u6b64\u8fd8\u8981\u586b\u5145\u4e4b\u95f4\u7684\u51e0\u4e2a\u5751&#xff1a;<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u7ec6\u8282\u4e00&#xff1a;<\/span><\/p>\n<p>\u5982\u679c\u5728\u8fdb\u7a0b\u89e3\u9664\u5bf9\u67d0\u4fe1\u53f7\u7684\u963b\u585e\u4e4b\u524d\u8fd9\u79cd\u4fe1\u53f7\u4ea7\u751f\u8fc7\u591a\u6b21,\u5c06\u5982\u4f55\u5904\u7406?<\/p>\n<p>POSIX.1\u5141\u8bb8\u7cfb\u7edf\u9012\u9001\u8be5\u4fe1\u53f7\u4e00\u6b21\u6216\u591a\u6b21\u3002Linux\u662f\u8fd9\u6837\u5b9e\u73b0\u7684:\u5e38\u89c4\u4fe1\u53f7\u5728\u9012\u8fbe\u4e4b\u524d\u4ea7\u751f\u591a\u6b21\u53ea\u8ba1\u4e00\u6b21,\u800c\u5b9e\u65f6\u4fe1\u53f7\u5728\u9012\u8fbe\u4e4b\u524d\u4ea7\u751f\u591a\u6b21\u53ef\u4ee5\u4f9d\u6b21\u653e\u5728\u4e00\u4e2a\u961f\u5217\u91cc\u3002<\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u7ec6\u8282\u4e8c&#xff1a;corr\u548cterm\u4e4b\u95f4\u7684\u533a\u522b&#xff08;\u4e24\u8005\u90fd\u662f\u7ec8\u6b62\u4fe1\u53f7&#xff09;<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u7ed3\u8bba&#xff1a;<\/span><\/p>\n<p><span style=\"color:#0d0016\">core\u7684\u6838\u5fc3\u533a\u522b\u5c31\u662f&#xff1a;\u4f1a\u5728\u5f53\u524d\u8def\u5f84\u4e0b\u5f62\u6210\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u8fdb\u7a0b\u5f02\u5e38\u9000\u51fa\u7684\u65f6\u5019&#xff0c;\u8fdb\u7a0b\u5728\u5185\u5b58\u4e2d\u7684\u6838\u5fc3\u6570\u636e\u4f1a\u5728\u78c1\u76d8\u4e2d\u62f7\u8d1d\u4e00\u4efd&#xff0c;\u5f62\u6210\u4e00\u4e2a\u6587\u4ef6\u3002\u8fd9\u4e2a\u5c31\u53eb\u505a&#8212;&#8211;\u6838\u5fc3\u8f6c\u50a8<\/span><\/p>\n<\/p>\n<p><span style=\"color:#0d0016\">\u6838\u5fc3\u8f6c\u50a8\u7684\u76ee\u7684\u5c31\u662f\u652f\u6301debug&#xff0c;<\/span><\/p>\n<p><span style=\"color:#0d0016\">\u5f00\u542fcore dump,\u76f4\u63a5\u8fd0\u884c\u5d29\u6e83&#xff0c;gdb&#xff0c;core-file core&#xff0c;\u76f4\u63a5\u5e2e\u52a9\u6211\u4eec\u5b9a\u4f4d\u5230\u51fa\u9519\u884c&#8212; \u4e8b\u540e\u8c03\u8bd5\u3002<\/span><\/p>\n<\/p>\n<p>\u4e3a\u4ec0\u4e48\u4ece\u6765\u6ca1\u6709\u89c1\u8fc7\u8fd9\u4e2a\u6587\u4ef6&#xff1f;<\/p>\n<\/p>\n<p>\u5728\u4e91\u670d\u52a1\u5668\u4e0acore dump\u8fd9\u4e2a\u529f\u80fd\u662f\u9ed8\u8ba4\u5173\u95ed\u7684\u3002<\/p>\n<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u7981\u7528&#xff1f;<\/p>\n<p>\u8fd8\u4ea7\u751f\u5927\u91cf\u7684core dump \u4f1a\u9020\u6210\u50a8\u5b58\u7684\u6d6a\u8d39<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"260\" src=\"2025-08-1113b4a1t3qvb.png\" width=\"939\" \/><\/p>\n<\/p>\n<p>ulimit -a \u8fdb\u884c\u67e5\u770b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"246\" src=\"2025-08-11tuk0meu5hqa.png\" width=\"744\" \/><\/p>\n<\/p>\n<\/p>\n<\/p>\n<h2>4.\u6355\u6349\u4fe1\u53f7<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"199\" src=\"2025-08-11kvx5zvf3fiy.png\" width=\"662\" \/><\/p>\n<\/p>\n<p>\u73b0\u5728\u6211\u76f4\u63a5\u628a\u4fe1\u53f7\u6355\u6349\u7684\u6d41\u7a0b\u7ed3\u8bba\u7ed9\u6574\u7406\u51fa\u6765&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"647\" src=\"2025-08-111whdgcps5za.png\" width=\"838\" \/><\/p>\n<p>\u6839\u636e\u4e4b\u524d\u6211\u4eec\u7684\u4e00\u4e2a\u7ed3\u8bba&#xff1a;\u4f1a\u5728\u5408\u9002\u7684\u65f6\u5019\u5904\u7406\u4fe1\u53f7<\/p>\n<\/p>\n<p>1.\u5728\u4e3b\u51fd\u6570\u4e2d&#xff0c;\u5982\u679c\u6211\u4eec\u9047\u89c1\u4e86\u4e2d\u65ad\u00a0 \u5f02\u5e38&#xff0c;\u6216\u8005\u662f \u7cfb\u7edf\u8c03\u7528&#xff0c;\u4f1a\u8fdb\u884c\u7528\u6237\u5207\u6362&#xff0c;\u4ece\u7528\u6237\u6001-\u300b\u300b\u5185\u6838\u6001\u3002<\/p>\n<\/p>\n<p>2.\u6b64\u65f6\u6211\u5c31\u5904\u4e8e\u5185\u6838\u6001&#xff0c;\u4f1a\u8fdb\u884c\u4fe1\u53f7\u7684\u68c0\u67e5&#xff08;do_signal&#xff09;,\u5982\u4f55\u68c0\u67e5 &#xff1f;\u67e5\u8be2\u4e0b\u9762\u4e09\u5f20\u8868<\/p>\n<p>\u5148\u770bpending\u8868&#xff0c;\u518d\u770bblock\u8868&#xff0c;\u6700\u540e\u770bhangler\u8868\u5982\u4f55\u5904\u7406&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"156\" src=\"2025-08-115fzolwanxwr.png\" width=\"364\" \/><\/p>\n<p>\u6b64\u65f6\u5c31\u4f1a\u6709\u4e09\u79cd\u60c5\u51b5&#xff1a;<\/p>\n<p>1.\u5ffd\u7565&#xff08;SIG_DFL&#xff09;,\u6b64\u65f6\u53ea\u9700\u5c06pending\u8868\u6539\u62100&#xff0c;\u5728\u5207\u6362\u6210\u7528\u6237\u6001\u6267\u884c\u4e3b\u51fd\u6570\u540e\u9762\u7684\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p>2.\u9ed8\u8ba4&#xff08;SIG_DFL&#xff09;,\u6839\u636e\u7279\u5b9a\u4fe1\u53f7\u7684\u7ea6\u5b9a\u6765\u6267\u884c&#xff08;\u5927\u90e8\u5206\u9ed8\u8ba4\u52a8\u4f5c\u662f\u7ec8\u6b62&#xff09;&#xff0c;\u6b64\u65f6\u53ea\u9700\u5c06pending\u8868\u6539\u62100&#xff0c;\u5728\u5207\u6362\u6210\u7528\u6237\u6001\u6267\u884c\u4e3b\u51fd\u6570\u540e\u9762\u7684\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p>3.\u81ea\u5b9a\u4e49&#xff0c;\u4f1a\u5148\u5207\u6362\u6210\u7528\u6237\u6001\u6267\u884c\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u4ee3\u7801&#xff0c;\u6267\u884c\u5b8c\u540e&#xff0c;\u5728\u5207\u6362\u6210\u5185\u6838\u6001&#xff0c;\u5728\u5185\u6838\u7a7a\u95f4\u4e2d&#xff0c;\u518d\u5207\u6362\u6210\u7528\u6237\u6001<\/p>\n<\/p>\n<p>\u62bd\u8c61\u51fa\u6765\u5c31\u662f\u4e0b\u9762\u8fd9\u4e2a\u6d41\u7a0b\u8868&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"360\" src=\"2025-08-11qd2my2on0hr.png\" width=\"1081\" \/><\/p>\n<\/p>\n<\/p>\n<h3>4.1.\u5185\u6838\u6001\u548c\u7528\u6237\u6001<\/h3>\n<\/p>\n<h4>4.1.1.\u64cd\u4f5c\u7cfb\u7edf\u662f\u5982\u4f55\u8fd0\u884c\u7684<\/h4>\n<p><span style=\"color:#fe2c24\">\u64cd\u4f5c\u7cfb\u7edf\u662f\u5982\u4f55\u77e5\u9053\u952e\u76d8\u4e0a(\u786c\u4ef6)\u53d1\u9001\u6765\u4e86\u6570\u636e&#xff1f;<\/span><\/p>\n<p>\u5176\u5b9ecpu\u7684\u9488\u811a\u4e0e\u8fd9\u4e2a\u786c\u4ef6\u662f\u95f4\u63a5\u76f8\u8fde\u7684&#xff0c;\u5f53\u786c\u4ef6\u7ed9cpu\u53d1\u9001\u5b8c\u6210\u4ee5\u540e&#xff0c;\u4f1a\u8ddfcpu\u8bf4\u6211\u7684\u6570\u636e\u53d1\u9001\u597d\u4e86&#xff0c;\u4f60\u53ef\u4ee5\u8fdb\u884c\u63a5\u53d7\u4e86&#xff0c;\u8fd9\u4e2a\u64cd\u4f5c\u5c31\u53eb\u505a&#8212;-\u300b\u300b\u786c\u4ef6\u4e2d\u65ad<\/p>\n<p>\u6240\u4ee5<\/p>\n<p>cpu\u4e0d\u4f1a\u4e0d\u65ad\u5730\u67e5\u770b\u8fd9\u4e2a\u786c\u4ef6\u770b\u5b83\u53d1\u9001\u5b8c\u6ca1&#xff0c;cpu\u4e4b\u540e\u770b\u5185\u5b58\u4e2d\u5730\u6570\u636e&#xff0c;\u4f46\u662f\u770b\u51af\u8bfa\u4f9d\u66fc\u4f53\u7cfb\u8fd9\u4e9b\u786c\u4ef6\u662f\u548ccpu\u6709\u8fde\u63a5\u7684<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"364\" src=\"2025-08-11ko1td3zjlay.png\" width=\"605\" \/><\/p>\n<\/p>\n<h5>4.1.1.1.\u786c\u4ef6\u4e2d\u65ad<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"555\" src=\"2025-08-11llcwzmx0ksg.png\" width=\"1178\" \/><\/p>\n<\/p>\n<p>\u6b64\u65f6\u6211\u4eec\u8981\u5c06\u8bdd\u9898\u5206\u6210\u4e24\u4e2a\u90e8\u5206&#xff0c;\u8fdb\u884c\u8bb2\u89e3&#xff1a;\u786c\u4ef6\u90e8\u5206\u548c\u8f6f\u4ef6\u90e8\u5206<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u786c\u4ef6\u90e8\u5206&#xff1a;<\/span><\/p>\n<p>\u6709\u4e0a\u9762\u7684\u77e5\u8bc6&#xff1a;\u786c\u4ef6\u548ccpu\u5176\u5b9e\u662f\u95f4\u63a5\u8fde\u63a5\u7684&#061;&#061;\u300b\u300b\u4e2d\u65ad\u63a7\u5236\u5668<\/p>\n<p><span style=\"color:#fe2c24\">\u6240\u4ee5\u6b64\u65f6\u7684\u64cd\u4f5c\u6d41\u7a0b&#xff1a;<\/span><\/p>\n<p>1.\u5916\u90e8\u8bbe\u5907\u8f93\u5165\u5b8c\u6210&#xff0c;\u901a\u8fc7\u7279\u5b9a\u7684\u9488\u811a\u5411\u4e2d\u65ad\u63a7\u5236\u5668\u53d1\u9001\u4e00\u4e2a\u9ad8\u9891\u4fe1\u53f7&#xff0c;\u6b64\u65f6\u4e2d\u65ad\u63a7\u5236\u5668&#xff0c;\u6839\u636e\u662f\u54ea\u4e2a\u9488\u811a\u7ed9\u6211\u53d1\u9001\u7684\u9ad8\u9891\u4fe1\u53f7&#xff0c;\u5224\u65ad\u51fa\u662f\u54ea\u4e2a\u786c\u4ef6\u7ed9\u6211\u53d1\u9001\u7684\u5f62\u6210\u4e00\u4e2a\u4e2d\u65ad\u53f7\u3002<\/p>\n<\/p>\n<p>2.\u6b64\u65f6\u7684\u4e2d\u65ad\u63a7\u5236\u5668&#xff0c;\u901a\u8fc7\u7279\u5b9a\u7684\u9488\u811a\u5411cpu\u53d1\u9001\u4e00\u4e2a\u9ad8\u9891\u4fe1\u53f7&#xff0c;cpu\u63a5\u53d7\u5230\u4e86\u4fe1\u53f7&#xff0c;\u5c31\u4f1a\u5411\u4e2d\u65ad\u63a7\u5236\u5668\u4e2d\u8bbf\u95ee\u5f62\u6210\u7684\u4e2d\u65ad\u53f7<\/p>\n<\/p>\n<p>3.\u6839\u636e\u4e2d\u65ad\u53f7&#xff0c;\u5c31\u77e5\u9053\u54ea\u4e00\u4e2a\u5916\u90e8\u8bbe\u5907\u51c6\u5907\u597d\u4e86CPU\u5c31\u77e5\u9053\u4e86!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"522\" src=\"2025-08-11biv0iipde4r.png\" width=\"981\" \/><\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u8f6f\u4ef6\u90e8\u5206&#xff1a;<\/span><\/p>\n<\/p>\n<p>\u6b64\u65f6\u786c\u4ef6\u90e8\u5206\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u4e2d\u65ad\u53f7&#xff0c;\u4f46\u662f\u6839\u636e\u4e2d\u65ad\u53f7\u5982\u4f55\u5904\u7406&#xff0c;\u8fd9\u4e2a\u53ea\u80fd\u4ea4\u7ed9\u8f6f\u4ef6\u90e8\u5206\u5904\u7406<\/p>\n<\/p>\n<p>1.\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u5728\u5185\u90e8\u63d0\u4f9b\u4e00\u5f20\u4e2d\u65ad\u5411\u91cf\u8868&#xff08;\u5c31\u662f\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u6570\u7ec4&#xff09;<\/p>\n<\/p>\n<p>2.cpu\u518d\u6839\u636e\u7ed9\u5b9a\u7684\u4e2d\u65ad\u53f7&#xff0c;\u627e\u5230\u6211\u4eec\u8981\u6267\u884c\u7684\u4e2d\u65ad\u65b9\u6cd5<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"619\" src=\"2025-08-11pwzeativ0ak.png\" width=\"962\" \/><\/p>\n<\/p>\n<\/p>\n<h5>4.1.1.2.\u65f6\u949f\u4e2d\u65ad<\/h5>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u5f53\u6ca1\u6709\u4e2d\u65ad\u5230\u6765\u7684\u65f6\u5019&#xff0c;OS\u5728\u505a\u4ec0\u4e48&#xff1f;<\/span><\/p>\n<p>\u4ec0\u4e48\u90fd\u6ca1\u505a&#xff0c;OS\u662f\u6682\u505c\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"64\" src=\"2025-08-11l13nk3exf5y.png\" width=\"147\" \/><\/p>\n<\/p>\n<p>1.\u6b64\u65f6\u5916\u90e8\u8bbe\u5907\u6709\u4e2a\u53eb\u505a\u65f6\u949f\u6e90\u7684\u4e1c\u897f&#xff0c;\u5b83\u4f1a\u4ee5\u56fa\u5b9a\u7684&#xff0c;\u7279\u5b9a\u7684\u9891\u7387&#xff0c;\u5411CPU\u53d1\u9001\u7279\u5b9a\u7684\u4e2d\u65ad<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"100\" src=\"2025-08-11xnzc25nkewq.png\" width=\"547\" \/><\/p>\n<\/p>\n<p>2.\u6b64\u65f6cpu\u5c31\u4f1a\u4ee5\u4e00\u5b9a\u7684\u9891\u7387\u6267\u884c\u8fdb\u7a0b\u8c03\u5ea6<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"47\" src=\"2025-08-11nhi12kahda5.png\" width=\"508\" \/><\/p>\n<\/p>\n<p>3.\u4f46\u662f\u5982\u679c\u5c06\u65f6\u949f\u6e90\u8bbe\u8ba1\u518d\u5916\u90e8&#xff0c;\u6b64\u65f6\u65f6\u949f\u6e90\u5c31\u4f1a\u4e0d\u65ad\u5730\u548c\u5176\u4ed6\u7684\u5916\u90e8\u8bbe\u5907\u62a2\u593a\u4e2d\u65ad\u53f7&#xff0c;\u4f1a\u964d\u4f4e\u6548\u7387&#xff0c;\u6240\u4ee5\u73b0\u5728\u7684\u65f6\u949f\u6e90\u90fd\u662fcpu\u5d4c\u8bbe\u8ba1\u7684<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"233\" src=\"2025-08-11xinu32pxi1r.png\" width=\"249\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"562\" src=\"2025-08-11g0tqvziiu4z.png\" width=\"960\" \/><\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u64cd\u4f5c\u7cfb\u7edf\u662f\u4ec0\u4e48?<\/span><\/p>\n<p>\n\u64cd\u4f5c\u7cfb\u7edf&#xff0c;\u5c31\u662f\u57fa\u4e8e\u4e2d\u65ad&#xff0c;\u8fdb\u884c\u5de5\u4f5c\u7684\u8f6f\u4ef6!<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u65f6\u95f4\u7247\u7684\u6982\u5ff5&#xff1a;<\/span><\/p>\n<p><span style=\"color:#0d0016\">schedule&#xff1a;\u8fdb\u7a0b\u8c03\u5ea6<\/span><\/p>\n<p>\u65f6\u95f4\u7247\u8017\u5c3d\u4e86&#xff0c;\u5c31\u4f1a\u8fdb\u884c\u8fdb\u7a0b\u7684\u8c03\u5ea6<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"127\" src=\"2025-08-115puf3vzmtta.png\" width=\"252\" \/><\/p>\n<\/p>\n<p>\u7531\u5916\u90e8\u8bbe\u5907\u89e6\u53d1\u7684&#xff0c;\u4e2d\u65ad\u7cfb\u7edf\u8fd0\u884c\u6d41\u7a0b&#xff0c;\u53eb\u505a\u786c\u4ef6\u4e2d\u65ad&#xff0c;\u6240\u4ee5\u65f6\u949f\u4e2d\u65ad\u4e5f\u662f\u786c\u4ef6\u4e2d\u65ad\u7684\u4e00\u79cd<br \/>\n\u00a0<\/p>\n<\/p>\n<\/p>\n<h5>4.1.1.3.\u786c\u4ef6\u5f02\u5e38<\/h5>\n<\/p>\n<p>\u5728\u00a0\u8fdb\u7a0b\u4fe1\u53f7\u9886\u57df&#xff0c;\u91ce\u6307\u9488\u8bbf\u95ee\u00a0\u548c\u00a0\u9664\u96f6\u9519\u8bef\u00a0\u65e2\u4e0d\u662f\u4f20\u7edf\u7684\u786c\u4ef6\u4e2d\u65ad&#xff0c;\u4e5f\u4e0d\u662f\u7eaf\u7cb9\u7684\u8f6f\u4e2d\u65ad&#xff0c;\u800c\u662f\u00a0\u201c\u786c\u4ef6\u68c0\u6d4b\u5f02\u5e38 \u2192 \u5185\u6838\u8f6c\u6362\u4e3a\u8f6f\u4e2d\u65ad&#xff08;\u4fe1\u53f7&#xff09;\u201d\u00a0\u7684\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p>\u5e38\u89c1\u7684\u786c\u4ef6\u5f02\u5e38\u6709&#xff1a;\u96640&#xff0c;\u91ce\u6307\u9488&#xff0c;\u6307\u9488\u91cd\u590d\u91ca\u653e&#xff0c;\u7f3a\u9875\u4e2d\u65ad<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u4ee5\u9664\u96f6\u5f02\u5e38\u4e3a\u4f8b&#xff1a;<\/span><\/p>\n<\/p>\n<p>1.\u8fdb\u7a0b\u5728\u6267\u884c\u81ea\u5df1\u7684\u4ee3\u7801\u7684\u65f6\u5019&#xff0c;\u6267\u884c\u5230\u9664\u96f6&#xff0c;cpu\u4e0a\u4f1a\u53d1\u751f\u786c\u4ef6\u4e0a\u7684\u6ea2\u51fa\u3002<\/p>\n<\/p>\n<p>2.\u4f46\u662f\u6b64\u65f6cpu\u4e0d\u77e5\u9053\u540e\u9762\u8be5\u600e\u4e48\u5904\u7406&#xff0c;\u6240\u4ee5\u5c31\u89c4\u5b9a\u6210\u4e3a\u4e00\u79cd\u6709CPU\u5185\u90e8\u89e6\u53d1\u7684\u4e2d\u65ad\u3002<\/p>\n<\/p>\n<p>3.\u6b64\u65f6cpu\u5185\u90e8\u5c31\u751f\u6210\u4e00\u4e2a\u7279\u6709\u7684\u4e2d\u65ad\u53f7&#xff0c;\u518d\u53bb\u4e2d\u65ad\u5411\u91cf\u8868\u4e2d&#xff0c;\u53bb\u6267\u884c\u5f02\u5e38\u4e2d\u65ad<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"40\" src=\"2025-08-11mvcyr3eurzx.png\" width=\"463\" \/><\/p>\n<\/p>\n<\/p>\n<\/p>\n<h5>4.1.1.4.\u8f6f\u4e2d\u65ad<\/h5>\n<\/p>\n<p><span style=\"color:#fe2c24\">CPU\u5185\u90e8&#xff0c;\u81ea\u5df1\u53ef\u4ee5 \u53ef\u4ee5\u8ba9\u8f6f\u4ef6\u89e6\u53d1\u4e2d\u65ad\u5417?<\/span><\/p>\n<p>\n\u5176\u5b9e\u6709\u4e0b\u9762\u4e24\u4e2a&#xff08;\u4e0d\u540c\u7248\u672c&#xff09;\u6307\u4ee4\u96c6\u53ef\u4ee5\u8ba9CPU\u901a\u8fc7\u8f6f\u4ef6\u4e3b\u52a8\u4e2d\u65ad<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"68\" src=\"2025-08-11rs0hmqcwgpf.png\" width=\"171\" \/><\/p>\n<\/p>\n<p>1.\u800c\u6211\u4eecC\/C&#043;&#043;\u4ee3\u7801:\u672c\u8d28\u5c31\u662f\u7f16\u8bd1\u6210\u4e3a\u4e86\u6307\u4ee4\u96c6&#043;\u6570\u636e<\/p>\n<\/p>\n<p>2.\u6240\u4ee5syscall\u5c31\u4f1a\u8ba9cpu\u5185\u90e8\u8fdb\u884c\u4e2d\u65ad&#xff0c;\u5e76\u751f\u6210\u4e00\u4e2a\u4e2d\u65ad\u5411\u91cf\u8868\u7684\u7f16\u53f7 &#8211;80&#xff08;\u5c31\u76f8\u5f53\u4e8e\u4e4b\u95f4\u786c\u4ef6\u5f02\u5e38\u7684\u6d41\u7a0b&#xff09;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"103\" src=\"2025-08-11o5a0fkesv3k.png\" width=\"471\" \/><\/p>\n<\/p>\n<p>3.\u6b64\u65f60x80\u5bf9\u5e94\u7684\u65b9\u6cd5\u5047\u8bbe\u4f1a\u505a\u4e0b\u9762\u51e0\u4ef6\u4e8b<\/p>\n<p>A.\u83b7\u53d6\u7cfb\u7edf\u8c03\u7528\u53f7 n<\/p>\n<p>B.\u8c03\u7528\u7cfb\u7edf\u8c03\u7528\u7684\u65b9\u6cd5<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"172\" src=\"2025-08-11zzrrwnlppp3.png\" width=\"772\" \/><\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u4e3a\u4e86\u66f4\u597d\u7684\u7406\u89e3\u4e0a\u9762\u7b2c\u4e09\u6b65\u7684\u6b65\u9aa4\u6211\u4eec\u8981\u4e86\u89e3\u51e0\u7ec4\u6982\u5ff5<\/span><\/p>\n<\/p>\n<p>1.\u7cfb\u7edf\u8c03\u7528\u8868&#xff1a;\u4ece\u6b64\u5f80\u540e&#xff0c;\u6bcf\u4e00\u4e2a\u7cfb\u7edf\u8c03\u7528&#xff0c;\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684\u4e0b\u6807&#xff0c;\u8fd9\u4e2a\u4e0b\u6807&#xff0c;\u6211\u4eec\u53eb\u505a&#xff0c;\u7cfb\u7edf\u8c03\u7528\u53f7<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"400\" src=\"2025-08-11cbfxztpvc5d.png\" width=\"798\" \/><\/p>\n<\/p>\n<p>2.\u5f53\u6211\u4eec\u8fdb\u884c\u7cfb\u7edf\u8c03\u7528\u7684\u65f6\u5019&#xff0c;\u5177\u4f53\u662f\u600e\u4e48\u8fdb\u5165\u64cd\u4f5c\u7cfb\u7edf&#xff1f;\u5b8c\u6210\u7cfb\u7edf\u8c03\u7528\u8fc7\u7a0b\u7684<\/p>\n<\/p>\n<p>\u4ee5open&#xff08;&#xff09;\u65b9\u6cd5\u4e3a\u4f8b&#xff0c;\u7528\u6237\u5c42\u9762\u4f1a\u8fdb\u884c\u4e0b\u9762\u7684\u64cd\u4f5c&#xff0c;\u7ed9\u5b9a\u6307\u5b9a\u7684\u7cfb\u7edf\u8c03\u7528\u53f7\u7ed9cpu\u7684\u5bc4\u5b58\u5668\u4e2d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"92\" src=\"2025-08-11tdktbzw25fi.png\" width=\"183\" \/><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u6240\u4ee5\u6b64\u65f6\u6211\u4eec\u4e5f\u53ef\u4ee5\u5f97\u51fa\u4e00\u4e2a\u7ed3\u8bba&#xff1a;<\/span><br \/>\n\u00a0<\/p>\n<p><span style=\"color:#fe2c24\">os\u64cd\u4f5c\u7cfb\u7edf&#xff0c;\u4e0d\u4f1a\u63d0\u4f9b\u4efb\u4f55\u7684\u63a5\u53e3&#xff0c;\u53ea\u4f1a\u63d0\u4f9b\u7cfb\u7edf\u8c03\u7528\u53f7&#xff0c;\u800c\u6240\u8c13\u7684open&#xff08;&#xff09;&#xff0c;fork&#xff08;&#xff09;\u65b9\u6cd5\u53ea\u662f<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u88abglibc\u7ed9\u5206\u88c5\u800c\u5df2<\/span><\/p>\n<\/p>\n<\/p>\n<\/p>\n<h3>4.2.\u5185\u6838\u6001\u548c\u7528\u6237\u6001\u603b\u7ed3<\/h3>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1419\" src=\"2025-08-11rd32som1kvv.png\" width=\"1061\" \/><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u6b64\u65f6\u7684\u603b\u7ed3\u5c31\u662f\u5bf9\u4e0a\u9762\u8fd9\u5f20\u56fe\u7684\u89e3\u6790&#xff1a;<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u524d\u63d0&#xff1a;<\/span><\/p>\n<p>1.\u4e4b\u524d\u6211\u4eec\u8bb2\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4\u4e0d\u4ec5\u5305\u62ec\u7528\u6237\u533a[0~3]\u8fd8\u5305\u62ec\u5185\u6838\u533a[3~4]&#xff0c;\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u7528\u6237\u7684\u9875\u8868\u6620\u5c04\u8bbf\u95ee\u5230\u7528\u6237\u7684\u78c1\u76d8\u6570\u636e&#xff0c;\u901a\u8fc7\u5185\u6838\u7684\u9875\u8868\u6620\u5c04\u5c31\u53ef\u4ee5\u8bbf\u95ee\u5230\u5185\u6838\u7684\u78c1\u76d8\u6570\u636e\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"254\" src=\"2025-08-11dzfvatrjcd5.png\" width=\"106\" \/><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u7ed3\u8bba&#xff1a;<\/span><\/p>\n<p>2.\u64cd\u4f5c\u7cfb\u7edf\u4e5f\u662f\u8f6f\u4ef6&#xff0c;\u4e00\u5b9a\u4e5f\u5728\u5185\u5b58\u5f53\u4e2d&#xff0c;\u7cfb\u7edf\u4e2d\u5185\u5b58\u53ea\u6709\u4e00\u4efd&#xff0c;\u6240\u6709\u7684\u8fdb\u7a0b\u5171\u4eab\u3002\u8fd9\u5c31\u610f\u5473\u7740&#xff0c;\u65e0\u8bba\u8fdb\u7a0b\u5982\u4f55\u7684\u8c03\u5ea6&#xff0c;\u6211\u4eec\u7684\u8fdb\u7a0b\u603b\u662f\u80fd\u591f\u627e\u5230\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"209\" src=\"2025-08-1142mxqeakxnd.png\" width=\"370\" \/><\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u95ee\u9898&#xff1a;<br \/>\n\u7528\u6237\u548c\u5185\u6838&#xff0c;\u90fd\u5728\u540c\u4e00\u4e2a[0,4GB]\u7684\u5730\u5740\u7a7a\u95f4\u4e0a\u4e86&#xff0c;\u5982\u679c\u7528\u6237&#xff0c;\u968f\u4fbf\u62ff\u4e00\u4e2a\u865a\u62df\u5730\u5740[3,4GB]&#xff0c;\u7528\u6237\u4e0d\u5c31\u53ef\u4ee5\u968f\u4fbf\u8bbf\u95ee\u5185\u6838\u4e2d\u7684\u4ee3\u7801\u548c\u6570\u636e\u4e86\u5417?<\/span><\/p>\n<p>\nOS\u4e3a\u4e86\u4fdd\u62a4\u81ea\u5df1&#xff0c;\u4e0d\u76f8\u4fe1\u4efb\u4f55\u4eba&#xff0c;\u5fc5\u987b\u91c7\u7528\u7cfb\u7edf\u8c03\u7528\u7684\u65b9\u5f0f\u8fdb\u884c\u8bbf\u95ee<\/p>\n<p>\n1.\u7528\u6237\u6001:\u4ee5\u7528\u6237\u8eab\u4efd&#xff0c;\u53ea\u80fd\u8bbf\u95ee\u81ea\u5df1\u7684[0,3GB]<\/p>\n<p>2.\u5185\u6838\u6001:\u4ee5\u5185\u6838\u7684\u8eab\u4efd&#xff0c;\u8fd0\u884c\u4f60\u901a\u8fc7\u7cfb\u7edf\u8c03\u7528\u7684\u65b9\u5f0f&#xff0c;\u8bbf\u95eeOS[3,4GB]<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u95ee\u9898<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u5728\u7cfb\u7edf\u4e2d&#xff0c;\u7528\u6237\u6216\u8005OS\u81ea\u5df1&#xff0c;\u600e\u4e48\u77e5\u9053\u5f53\u524d\u5904\u4e8e\u5185\u6838\u6001&#xff0c;\u8fd8\u662f\u7528\u6237\u6001?<\/span><\/p>\n<\/p>\n<p>CPU\u4e2d\u6709\u4e2acs\u6bb5\u5bc4\u5b58\u5668&#xff0c;\u63a7\u5236\u4e24\u4e2abit\u4f4d&#xff0c;<\/p>\n<p>11-&gt;3:\u7528\u6237\u6001<\/p>\n<p>00-&gt;0:\u5185\u6838\u6001<\/p>\n<\/p>\n<p>\u6240\u4ee5&#xff1a;\u5176\u5b9e\u5c31\u662f\u66f4\u6539cs\u5bc4\u5b58\u5668\u6bb5\u7684\u6570\u636e\u5b8c\u6210\u8eab\u4efd\u4e4b\u95f4\u7684\u5207\u6362<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"540\" src=\"2025-08-11toiloiujxbe.png\" width=\"279\" \/><\/p>\n<\/p>\n<\/p>\n<h3>4.3.sigaction\u4fe1\u53f7\u6355\u6349<\/h3>\n<\/p>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"82\" src=\"2025-08-11ijud3rpcd5k.png\" width=\"683\" \/><\/p>\n<\/p>\n<p>\u53c2\u6570\u8bb2\u89e3&#xff1a;<br \/>\n\u00a0<\/p>\n<ul>\n<li>signum&#xff1a;\u4fe1\u53f7\u7f16\u53f7&#xff08;\u5982\u00a0SIGINT\u3001SIGTERM&#xff09;\u3002<\/li>\n<li>act&#xff1a;\u6307\u5411\u00a0struct sigaction\u00a0\u7684\u6307\u9488&#xff0c;\u7528\u4e8e\u8bbe\u7f6e\u65b0\u7684\u4fe1\u53f7\u5904\u7406\u65b9\u5f0f\u3002<\/li>\n<li>oldact&#xff1a;\u8f93\u51fa\u53c2\u6570&#xff0c;\u4fdd\u5b58\u65e7\u7684\u4fe1\u53f7\u5904\u7406\u914d\u7f6e&#xff08;\u82e5\u4e0d\u4e3a\u00a0NULL&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de\u00a00&#xff0c;\u5931\u8d25\u8fd4\u56de\u00a0-1&#xff08;\u5e76\u8bbe\u7f6e\u00a0errno&#xff09;\u3002<\/p>\n<\/p>\n<p>\u5176\u5b9e\u8fd9\u4e2a\u6355\u6349\u51fd\u6570\u548c\u4e4b\u524d\u90a3\u4e2asignal\u51fd\u6570\u5341\u5206\u7684\u76f8\u4f3c&#xff0c;\u4e0b\u9762\u662f\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<br \/>\n#include &lt;cstdlib&gt;<\/p>\n<p>void handler(int signum)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;hello signal: &#034; &lt;&lt; signum &lt;&lt; std::endl;<br \/>\n    exit(0);<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    struct sigaction act, oact;<br \/>\n    act.sa_handler &#061; handler;<\/p>\n<p>    sigaction(SIGINT, &amp;act, &amp;oact); \/\/ \u5bf92\u53f7\u4fe1\u53f7\u8fdb\u884c\u4e86\u6355\u6349<\/p>\n<p>    while(true)<br \/>\n    {<br \/>\n        std::cout &lt;&lt; &#034;hello world&#034; &lt;&lt; std::endl;<br \/>\n        sleep(1);<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<\/p>\n<p>\u8fd9\u662fstruct sigaction\u7ed3\u6784\u4f53&#xff0c;\u6b64\u65f6\u6211\u4eec\u7684\u91cd\u70b9\u805a\u7126\u5728\u4fe1\u53f7\u96c6\u4e0a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"337\" src=\"2025-08-11r2h20ew3fpo.png\" width=\"738\" \/><\/p>\n<\/p>\n<p>\u5f53\u67d0\u4e2a\u4fe1\u53f7\u7684\u5904\u7406\u51fd\u6570\u88ab\u8c03\u7528\u65f6,\u5185\u6838\u81ea\u52a8\u5c06\u5f53\u524d\u4fe1\u53f7\u52a0\u5165\u8fdb\u7a0b\u7684\u4fe1\u53f7\u5c4f\u853d\u5b57,\u5f53\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u8fd4\u56de\u65f6\u81ea\u52a8\u6062\u590d\u539f\u6765\u7684\u4fe1\u53f7\u5c4f\u853d\u5b57,\u8fd9\u6837\u5c31\u4fdd\u8bc1\u4e86\u5728\u5904\u7406\u67d0\u4e2a\u4fe1\u53f7\u65f6,\u5982\u679c\u8fd9\u79cd\u4fe1\u53f7\u518d\u6b21\u4ea7\u751f,\u90a3\u4e48 \u5b83\u4f1a\u88ab\u963b\u585e\u5230\u5f53\u524d\u5904\u7406\u7ed3\u675f\u4e3a\u6b62\u3002\u5982\u679c\u5728\u8c03\u7528\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u65f6,\u9664\u4e86\u5f53\u524d\u4fe1\u53f7\u88ab\u81ea\u52a8\u5c4f\u853d\u4e4b\u5916,\u8fd8\u5e0c\u671b\u81ea\u52a8\u5c4f\u853d\u53e6\u5916-\u4e9b\u4fe1\u53f7,\u5219\u7528sa mask\u5b57\u6bb5\u8bf4\u660e\u8fd9\u4e9b\u9700\u8981\u989d\u5916\u5c4f\u853d\u7684\u4fe1\u53f7,\u5f53\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u8fd4\u56de\u65f6\u81ea\u52a8\u6062\u590d\u539f\u6765\u7684\u4fe1\u53f7\u5c4f\u853d\u5b57\u3002\u00a0<\/p>\n<\/p>\n<p>\u901a\u4fd7\u6765\u8bb2\u5c31\u662f\u6355\u6349\u5230\u6307\u5b9a\u7684\u4fe1\u53f7\u96c6\u7684\u65f6\u5019&#xff0c;\u4f1a\u628a\u4ed6\u76f8\u5bf9\u5e94\u7684block\u8868\u7f6e\u4e3a1&#xff0c;\u8fdb\u884c\u963b\u585e&#xff0c;\u9632\u6b62\u591a\u4e2a\u4fe1\u53f7\u540c\u65f6\u6765\u7684\u60c5\u51b5<\/p>\n<\/p>\n<\/p>\n<\/p>\n<h2>5.\u8fdb\u7a0b\u4fe1\u53f7\u884d\u751f\u7684\u51e0\u7ec4\u95ee\u9898<\/h2>\n<\/p>\n<h3>5.1.\u53ef\u91cd\u5165\u51fd\u6570<\/h3>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u63a5\u4e0b\u6765\u6211\u5c06\u4e3e\u4f8b\u4e00\u4e2a\u94fe\u8868\u5934\u63d2\u7684\u4f8b\u5b50&#xff1a;<\/span><\/p>\n<p><span style=\"color:#ad720d\">\u5934\u63d2\u5206\u6210\u4e24\u4e2a\u6b65\u9aa4&#xff1a;<\/span><\/p>\n<p><span style=\"color:#ad720d\">A.\u65b0\u52a0\u5165\u7684\u8282\u70b9\u7684\u4e0b\u4e00\u4e2a\u8282\u70b9\u6307\u5411head\u7684\u4e0b\u4e00\u4e2a\u8282\u70b9\u3002<\/span><\/p>\n<p><span style=\"color:#ad720d\">B.head\u8282\u70b9\u7684\u4e0b\u4e00\u4e2a\u8282\u70b9\u6307\u5411\u65b0\u52a0\u5165\u7684\u8282\u70b9\u3002<\/span><\/p>\n<\/p>\n<p>1.\u5047\u8bbe\u6b64\u65f6node1\u8981\u5934\u63d2\u5230head\u8282\u70b9\u540e\u9762&#xff0c;\u5f53\u5b83\u6267\u884c\u5b8cA&#xff0c;\u51c6\u5907\u6267\u884cB\u7684\u65f6\u5019&#xff0c;\u53d1\u751f\u4e86\u8fdb\u7a0b\u7684\u8c03\u5ea6\u3002<\/p>\n<\/p>\n<p>2.\u6b64\u65f6node2\u4e5f\u8981\u5934\u63d2\u5230head\u8282\u70b9\u540e\u9762&#xff0c;\u5f53node2\u63d2\u5165\u5b8c\u7684\u65f6\u5019\u3002\u53c8\u53d1\u751f\u4e86\u8fdb\u7a0b\u7684\u8c03\u5ea6\u5230node1\u5934\u63d2\u7684\u8fdb\u7a0b\u3002<\/p>\n<\/p>\n<p>3.\u6b64\u65f6\u6267\u884cB\u64cd\u4f5c&#xff0c;\u6700\u540e\u5c31\u4f1a\u9020\u6210\u4e0b\u56fe4\u7684\u73b0\u8c61&#xff0c;\u9020\u6210node2\u6570\u636e\u7684\u4e22\u5931<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"590\" src=\"2025-08-114vqtvntxttp.png\" width=\"942\" \/><\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u603b\u7ed3&#xff1a;<\/span><\/p>\n<p>\u4e0d\u53ef\u91cd\u5165\u51fd\u6570\u548c\u53ef\u91cd\u5165\u51fd\u6570\u53ea\u662f\u4e00\u4e2a\u7279\u6027\u3002<\/p>\n<p><span style=\"color:#ad720d\">\u4e0d\u53ef\u91cd\u5165\u51fd\u6570&#xff1a;<\/span><\/p>\n<p>\u5927\u90e8\u5206\u7684\u51fd\u6570&#xff0c;\u90fd\u662f\u4e0d\u53ef\u91cd\u5165\u7684<br \/>\n\u8c03\u7528\u4e86malloc\u6216free,\u56e0\u4e3amalloc\u4e5f\u662f\u7528\u5168\u5c40\u94fe\u8868\u6765\u7ba1\u7406\u5806\u7684\u3002\u8c03\u7528\u4e86\u6807\u51c6I\/0\u5e93\u51fd\u6570\u3002\u6807\u51c6I\/0\u5e93\u7684\u5f88\u591a\u5b9e\u73b0\u90fd\u4ee5\u4e0d\u53ef\u91cd\u5165\u7684\u65b9\u5f0f\u4f7f\u7528\u5168\u5c40\u6570\u636e\u7ed3\u6784\u3002<\/p>\n<p>\n<span style=\"color:#ad720d\">\u53ef\u91cd\u5165\u51fd\u6570&#xff1a;<\/span><\/p>\n<p>\u53ea\u6709\u81ea\u5df1\u7684\u4e34\u65f6\u53d8\u91cf&#8211; \u53ef\u91cd\u5165\u7684\u3002<\/p>\n<\/p>\n<\/p>\n<h3>5.2.volatile<\/h3>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u4f9d\u65e7\u662f\u4e3e\u4e2a\u4f8b\u5b50&#xff1a;\u89c2\u5bdf\u4e0b\u9762\u4ee3\u7801&#xff0c;<\/span><\/p>\n<p><span style=\"color:#ad720d\">\u5bf9\u4e8eflag \u53d8\u91cf<\/span><\/p>\n<p>\u6b63\u5e38\u7684\u60c5\u51b5\u4e0b\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u8fdb\u884c\u4e0b\u9762\u64cd\u4f5c<\/p>\n<p><span style=\"color:#1c7331\">1.\u4e0d\u65ad\u7684\u4ece\u7269\u7406\u5185\u5b58\u4e2d\u53d6\u6570\u636e&#xff0c;\u770bfalg\u662f\u5426\u6539\u53d8<\/span><\/p>\n<p><span style=\"color:#1c7331\">2.\u5bf9falg\u53d8\u91cf\u8fdb\u884c\u5224\u65ad&#xff0c;\u662f\u5426\u7ed3\u675f\u5faa\u73af<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"246\" src=\"2025-08-11k1wqx3hlj0q.png\" width=\"757\" \/><\/p>\n<\/p>\n<p>\u4f46\u662f\u6b64\u65f6main\u51fd\u6570\u91cc\u4e0d\u4f1a\u5bf9flag\u53d8\u91cf\u8fdb\u884c\u6539\u53d8&#xff0c;\u6240\u6709\u5c31\u4f1a\u6709\u4e9b\u4f18\u5316\u7ea7\u522b\u9ad8\u7684\u7f16\u8f91\u5668&#xff0c;\u5c31\u4f1a\u628a\u4ece\u7269\u7406\u5185\u5b58\u4e2d\u62ff\u6570\u636e\u8fd9\u4e2a\u64cd\u4f5c\u7ed9\u780d\u65ad&#xff0c;\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<\/p>\n<p>\u6b64\u65f6volatile\u7684\u4f5c\u7528&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"39\" src=\"2025-08-11ovg4ysg1r0r.png\" width=\"466\" \/><\/p>\n<\/p>\n<\/p>\n<h3>5.3.SIGCHLD\u4fe1\u53f7<\/h3>\n<\/p>\n<p><span style=\"color:#1f2329\">\u2f26\u8fdb\u7a0b\u5728\u7ec8\u2f4c\u65f6\u4f1a\u7ed9\u2f57\u8fdb\u7a0b\u53d1SIGCHLD\u4fe1\u53f7,\u8be5\u4fe1\u53f7\u7684\u9ed8\u8ba4\u5904\u7406\u52a8\u4f5c\u662f\u5ffd\u7565,\u2f57\u8fdb\u7a0b\u53ef\u4ee5\u2f83 \u5b9a\u4e49 <\/span><\/p>\n<p><span style=\"color:#1f2329\">SIGCHLD\u4fe1\u53f7\u7684\u5904\u7406\u51fd\u6570<\/span><\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;signal.h&gt;<\/p>\n<p>void handler(int sig)<br \/>\n{<br \/>\n    pid_t id;<br \/>\n    while( (id &#061; waitpid(-1, NULL, WNOHANG)) &gt; 0 ) {<br \/>\n        printf(&#034;wait child success: %d\\\\n&#034;, id);<br \/>\n    }<br \/>\n    printf(&#034;child is quit! %d\\\\n&#034;, getpid());<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\n    signal(SIGCHLD, handler);<br \/>\n    pid_t cid;<br \/>\n    if((cid &#061; fork()) &#061;&#061; 0){\/\/child<br \/>\n        printf(&#034;child : %d\\\\n&#034;, getpid());<br \/>\n        sleep(3);<br \/>\n        exit(1);<br \/>\n    }<br \/>\n    while(1){<br \/>\n        printf(&#034;father proc is doing some thing!\\\\n&#034;);<br \/>\n        sleep(1);<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb82\u6b21\u3002\u6587\u7ae0\u6458\u8981 \u8fdb\u7a0b\u4fe1\u53f7\u662fLinux\u7cfb\u7edf\u4e2d\u7684\u91cd\u8981\u901a\u4fe1\u673a\u5236\uff0c\u7528\u4e8e\u5f02\u6b65\u901a\u77e5\u8fdb\u7a0b\u7279\u5b9a\u4e8b\u4ef6\u7684\u53d1\u751f\u3002\u4fe1\u53f7\u53ef\u5206\u4e3a\u5e38\u89c4\u4fe1\u53f7\u548c\u5b9e\u65f6\u4fe1\u53f7\uff0c\u53ef\u901a\u8fc7\u952e\u76d8\u8f93\u5165\u3001\u7cfb\u7edf\u8c03\u7528\u3001\u786c\u4ef6\u5f02\u5e38\u7b49\u65b9\u5f0f\u4ea7\u751f\u3002\u8fdb\u7a0b\u5bf9\u4fe1\u53f7\u7684\u5904\u7406\u5305\u62ec\u9ed8\u8ba4\u52a8\u4f5c\u3001\u5ffd\u7565\u4fe1\u53f7\u6216\u81ea\u5b9a\u4e49\u5904\u7406\u51fd\u6570\u3002\u5185\u6838\u901a\u8fc7pending\u8868\u3001block\u8868\u548chandler\u8868\u4e09\u5f20\u4f4d\u56fe\u7ed3\u6784\u7ba1\u7406\u4fe1\u53f7\u72b6\u6001\u3002\u4fe1\u53f7\u6355\u6349\u6d89\u53ca\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u7684\u5207\u6362\uff0c\u5176\u4e2d\u786c\u4ef6\u5f02\u5e38\u548c\u7cfb\u7edf\u8c03\u7528\u662f\u89e6\u53d1\u4fe1\u53f7\u7684\u4e3b\u8981\u9014\u5f84\u3002volatile\u5173\u952e\u5b57\u53ef\u9632\u6b62\u7f16\u8bd1\u5668\u4f18\u5316\u5bf9\u4fe1\u53f7\u53d8\u91cf\u7684\u8bbf\u95ee\uff0c\u800cSIGCHLD\u4fe1\u53f7\u5219\u7528\u4e8e\u7236\u8fdb\u7a0b\u76d1\u63a7\u5b50\u8fdb\u7a0b\u72b6\u6001\u3002\u4fe1\u53f7\u673a\u5236\u4f53\u73b0\u4e86\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u786c\u4ef6\u4e2d\u65ad<\/p>\n","protected":false},"author":2,"featured_media":52344,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,43,44],"topic":[],"class_list":["post-52364","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u8fdb\u7a0b\u4fe1\u53f7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/52364.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u8fdb\u7a0b\u4fe1\u53f7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb82\u6b21\u3002\u6587\u7ae0\u6458\u8981 \u8fdb\u7a0b\u4fe1\u53f7\u662fLinux\u7cfb\u7edf\u4e2d\u7684\u91cd\u8981\u901a\u4fe1\u673a\u5236\uff0c\u7528\u4e8e\u5f02\u6b65\u901a\u77e5\u8fdb\u7a0b\u7279\u5b9a\u4e8b\u4ef6\u7684\u53d1\u751f\u3002\u4fe1\u53f7\u53ef\u5206\u4e3a\u5e38\u89c4\u4fe1\u53f7\u548c\u5b9e\u65f6\u4fe1\u53f7\uff0c\u53ef\u901a\u8fc7\u952e\u76d8\u8f93\u5165\u3001\u7cfb\u7edf\u8c03\u7528\u3001\u786c\u4ef6\u5f02\u5e38\u7b49\u65b9\u5f0f\u4ea7\u751f\u3002\u8fdb\u7a0b\u5bf9\u4fe1\u53f7\u7684\u5904\u7406\u5305\u62ec\u9ed8\u8ba4\u52a8\u4f5c\u3001\u5ffd\u7565\u4fe1\u53f7\u6216\u81ea\u5b9a\u4e49\u5904\u7406\u51fd\u6570\u3002\u5185\u6838\u901a\u8fc7pending\u8868\u3001block\u8868\u548chandler\u8868\u4e09\u5f20\u4f4d\u56fe\u7ed3\u6784\u7ba1\u7406\u4fe1\u53f7\u72b6\u6001\u3002\u4fe1\u53f7\u6355\u6349\u6d89\u53ca\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u7684\u5207\u6362\uff0c\u5176\u4e2d\u786c\u4ef6\u5f02\u5e38\u548c\u7cfb\u7edf\u8c03\u7528\u662f\u89e6\u53d1\u4fe1\u53f7\u7684\u4e3b\u8981\u9014\u5f84\u3002volatile\u5173\u952e\u5b57\u53ef\u9632\u6b62\u7f16\u8bd1\u5668\u4f18\u5316\u5bf9\u4fe1\u53f7\u53d8\u91cf\u7684\u8bbf\u95ee\uff0c\u800cSIGCHLD\u4fe1\u53f7\u5219\u7528\u4e8e\u7236\u8fdb\u7a0b\u76d1\u63a7\u5b50\u8fdb\u7a0b\u72b6\u6001\u3002\u4fe1\u53f7\u673a\u5236\u4f53\u73b0\u4e86\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u786c\u4ef6\u4e2d\u65ad\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/52364.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-11T05:45:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054509-68998365dba64.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52364.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/52364.html\",\"name\":\"Linux\u8fdb\u7a0b\u4fe1\u53f7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-11T05:45:12+00:00\",\"dateModified\":\"2025-08-11T05:45:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/52364.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/52364.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52364.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u8fdb\u7a0b\u4fe1\u53f7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux\u8fdb\u7a0b\u4fe1\u53f7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/52364.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u8fdb\u7a0b\u4fe1\u53f7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb82\u6b21\u3002\u6587\u7ae0\u6458\u8981 \u8fdb\u7a0b\u4fe1\u53f7\u662fLinux\u7cfb\u7edf\u4e2d\u7684\u91cd\u8981\u901a\u4fe1\u673a\u5236\uff0c\u7528\u4e8e\u5f02\u6b65\u901a\u77e5\u8fdb\u7a0b\u7279\u5b9a\u4e8b\u4ef6\u7684\u53d1\u751f\u3002\u4fe1\u53f7\u53ef\u5206\u4e3a\u5e38\u89c4\u4fe1\u53f7\u548c\u5b9e\u65f6\u4fe1\u53f7\uff0c\u53ef\u901a\u8fc7\u952e\u76d8\u8f93\u5165\u3001\u7cfb\u7edf\u8c03\u7528\u3001\u786c\u4ef6\u5f02\u5e38\u7b49\u65b9\u5f0f\u4ea7\u751f\u3002\u8fdb\u7a0b\u5bf9\u4fe1\u53f7\u7684\u5904\u7406\u5305\u62ec\u9ed8\u8ba4\u52a8\u4f5c\u3001\u5ffd\u7565\u4fe1\u53f7\u6216\u81ea\u5b9a\u4e49\u5904\u7406\u51fd\u6570\u3002\u5185\u6838\u901a\u8fc7pending\u8868\u3001block\u8868\u548chandler\u8868\u4e09\u5f20\u4f4d\u56fe\u7ed3\u6784\u7ba1\u7406\u4fe1\u53f7\u72b6\u6001\u3002\u4fe1\u53f7\u6355\u6349\u6d89\u53ca\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u7684\u5207\u6362\uff0c\u5176\u4e2d\u786c\u4ef6\u5f02\u5e38\u548c\u7cfb\u7edf\u8c03\u7528\u662f\u89e6\u53d1\u4fe1\u53f7\u7684\u4e3b\u8981\u9014\u5f84\u3002volatile\u5173\u952e\u5b57\u53ef\u9632\u6b62\u7f16\u8bd1\u5668\u4f18\u5316\u5bf9\u4fe1\u53f7\u53d8\u91cf\u7684\u8bbf\u95ee\uff0c\u800cSIGCHLD\u4fe1\u53f7\u5219\u7528\u4e8e\u7236\u8fdb\u7a0b\u76d1\u63a7\u5b50\u8fdb\u7a0b\u72b6\u6001\u3002\u4fe1\u53f7\u673a\u5236\u4f53\u73b0\u4e86\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u786c\u4ef6\u4e2d\u65ad","og_url":"https:\/\/www.wsisp.com\/helps\/52364.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-11T05:45:12+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811054509-68998365dba64.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"13 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/52364.html","url":"https:\/\/www.wsisp.com\/helps\/52364.html","name":"Linux\u8fdb\u7a0b\u4fe1\u53f7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-11T05:45:12+00:00","dateModified":"2025-08-11T05:45:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/52364.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/52364.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/52364.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u8fdb\u7a0b\u4fe1\u53f7"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=52364"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52364\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/52344"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=52364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=52364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=52364"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=52364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}