{"id":84801,"date":"2026-07-26T18:17:56","date_gmt":"2026-07-26T10:17:56","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/84801.html"},"modified":"2026-07-26T18:17:56","modified_gmt":"2026-07-26T10:17:56","slug":"linux%e5%86%85%e6%a0%b8-%e5%86%85%e6%a0%b8%e4%bf%a1%e5%8f%b7%e5%a4%84%e7%90%86%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/84801.html","title":{"rendered":"Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570"},"content":{"rendered":"<h2 id=\"sigaction\u7ed3\u6784\u4f53\">sigaction\u7ed3\u6784\u4f53<\/h2>\n<p>\/\/ \u4e0b\u9762\u662f sigaction \u7684\u6570\u636e\u7ed3\u6784\u3002<br \/>\n \/\/ sa_handler \u662f\u5bf9\u5e94\u67d0\u4fe1\u53f7\u6307\u5b9a\u8981\u91c7\u53d6\u7684\u884c\u52a8\u3002\u53ef\u4ee5\u662f\u4e0a\u9762\u7684 SIG_DFL&#xff0c;\u6216\u8005\u662f SIG_IGN \u6765\u5ffd\u7565<br \/>\n \/\/ \u8be5\u4fe1\u53f7&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u6307\u5411\u5904\u7406\u8be5\u4fe1\u53f7\u7684\u4e00\u4e2a\u6307\u9488\u3002<br \/>\n \/\/ sa_mask \u7ed9\u51fa\u4e86\u5bf9\u4fe1\u53f7\u7684\u5c4f\u853d\u7801&#xff0c;\u5728\u4fe1\u53f7\u7a0b\u5e8f\u6267\u884c\u65f6\u5c06\u963b\u585e\u5bf9\u8fd9\u4e9b\u4fe1\u53f7\u7684\u5904\u7406\u3002<br \/>\n \/\/ sa_flags \u6307\u5b9a\u6539\u53d8\u4fe1\u53f7\u5904\u7406\u8fc7\u7a0b\u7684\u4fe1\u53f7\u96c6\u3002\u5b83\u662f\u7531 37-39 \u884c\u7684\u4f4d\u6807\u5fd7\u5b9a\u4e49\u7684\u3002<br \/>\n \/\/ \u53e6\u5916&#xff0c;\u5f15\u8d77\u89e6\u53d1\u4fe1\u53f7\u5904\u7406\u7684\u4fe1\u53f7\u4e5f\u5c06\u88ab\u963b\u585e&#xff0c;\u9664\u975e\u4f7f\u7528\u4e86 SA_NOMASK \u6807\u5fd7\u3002<br \/>\nstruct sigaction {<br \/>\n    void (*sa_handler)(int);<br \/>\n    sigset_t sa_mask;<br \/>\n    int sa_flags;<br \/>\n    void (*sa_restorer)(void);<br \/>\n};<\/p>\n<h2 id=\"do_signal\">do_signal<\/h2>\n<p>\u5b83\u7684\u6838\u5fc3\u4f5c\u7528\u662f&#xff1a;\u5728\u8fdb\u7a0b\u5373\u5c06\u4ece\u5185\u6838\u6001\u8fd4\u56de\u7528\u6237\u6001\u7684\u524d\u5915&#xff0c;\u68c0\u67e5\u5e76\u5904\u7406\u8be5\u8fdb\u7a0b\u6536\u5230\u7684\u5f85\u5904\u7406\u4fe1\u53f7\u3002<\/p>\n<p>\u5b83\u4e0d\u76f4\u63a5\u5bf9\u5e94\u4efb\u4f55\u4e00\u4e2a\u7cfb\u7edf\u8c03\u7528\u3002\u5b83\u662f\u7531\u6240\u6709\u7684\u7cfb\u7edf\u8c03\u7528&#xff08;\u4ee5\u53ca\u4e2d\u65ad\/\u5f02\u5e38&#xff09;\u5728\u8fd4\u56de\u7528\u6237\u6001\u65f6\u7edf\u4e00\u8c03\u7528\u7684\u201c\u94a9\u5b50\u51fd\u6570\u201d\u3002<\/p>\n<p> \/\/ \u7cfb\u7edf\u8c03\u7528\u4e2d\u65ad\u5904\u7406\u7a0b\u5e8f\u4e2d\u771f\u6b63\u7684\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f&#xff08;\u5728 kernel\/system_call.s,119 \u884c&#xff09;\u3002<br \/>\n \/\/ \u8be5\u6bb5\u4ee3\u7801\u7684\u4e3b\u8981\u4f5c\u7528\u662f\u5c06\u4fe1\u53f7\u7684\u5904\u7406\u53e5\u67c4\u63d2\u5165\u5230\u7528\u6237\u7a0b\u5e8f\u5806\u6808\u4e2d&#xff0c;\u5e76\u5728\u672c\u7cfb\u7edf\u8c03\u7528\u7ed3\u675f<br \/>\n \/\/ \u8fd4\u56de\u540e\u7acb\u523b\u6267\u884c\u4fe1\u53f7\u53e5\u67c4\u7a0b\u5e8f&#xff0c;\u7136\u540e\u7ee7\u7eed\u6267\u884c\u7528\u6237\u7684\u7a0b\u5e8f\u3002<br \/>\n\/**<br \/>\n * &#064;brief \u5904\u7406\u4fe1\u53f7\u4e2d\u65ad<br \/>\n *<br \/>\n * &#064;param signr \u4fe1\u53f7\u503c<br \/>\n * &#064;param eax \u901a\u5e38\u7528\u6765\u6267\u884c\u52a0\u6cd5&#xff0c;\u51fd\u6570\u8c03\u7528\u7684\u8fd4\u56de\u503c\u4e00\u822c\u4e5f\u653e\u5728\u8fd9\u91cc\u9762<br \/>\n * &#064;param ebx \u6570\u636e\u5b58\u53d6<br \/>\n * &#064;param ecx \u901a\u5e38\u7528\u6765\u4f5c\u4e3a\u8ba1\u6570\u5668&#xff0c;\u5982for\u5faa\u73af<br \/>\n * &#064;param edx \u8bfb\u5199I\/O\u7aef\u53e3\u65f6&#xff0c;edx\u7528\u6765\u5b58\u653e\u7aef\u53e3\u53f7<br \/>\n * &#064;param fs \u6587\u4ef6\u6570\u636e\u6bb5<br \/>\n * &#064;param es \u6269\u5c55\u6570\u636e\u6bb5<br \/>\n * &#064;param ds \u6570\u636e\u6bb5<br \/>\n * &#064;param eip \u6307\u4ee4\u5bc4\u5b58\u5668<br \/>\n * &#064;param cs \u4ee3\u7801\u6bb5<br \/>\n * &#064;param eflags \u6807\u5fd7\u5bc4\u5b58\u5668<br \/>\n * &#064;param esp \u6808\u9876\u6307\u9488<br \/>\n * &#064;param ss \u6808\u6bb5<br \/>\n *\/<br \/>\nvoid do_signal(long signr,long eax, long ebx, long ecx, long edx,<br \/>\n    long fs, long es, long ds,<br \/>\n    long eip, long cs, long eflags,<br \/>\n    unsigned long * esp, long ss)<\/p>\n<h3 id=\"\u51b3\u7b56\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u7684\u6267\u884c\">\u51b3\u7b56\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u7684\u6267\u884c<\/h3>\n<p>    unsigned long sa_handler;<br \/>\n    long old_eip&#061;eip;<br \/>\n    struct sigaction * sa &#061; current-&gt;sigaction &#043; signr &#8211; 1;<br \/>\n    int longs;<br \/>\n    unsigned long * tmp_esp;<\/p>\n<p>    sa_handler &#061; (unsigned long) sa-&gt;sa_handler;<br \/>\n    if (sa_handler&#061;&#061;1)  \/\/\u5982\u679c\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f\u4e3a\u53ef\u5ffd\u7565\u7684\u5c31\u76f4\u63a5\u8fd4\u56de<br \/>\n        return;<br \/>\n    if (!sa_handler) {<br \/>\n        if (signr&#061;&#061;SIGCHLD)  \/\/\u5982\u679c\u4fe1\u53f7\u5904\u7406\u4e3a\u9ed8\u8ba4\u5e76\u4e14\u4fe1\u53f7\u662fSIGCHLD\u5219\u8fd4\u56de<br \/>\n            return;<br \/>\n        else<br \/>\n            do_exit(1&lt;&lt;(signr-1)); \/\/\u5982\u679c\u4e0d\u662fSIGCHLD\u76f4\u63a5\u7ec8\u6b62\u8fdb\u7a0b<br \/>\n    }<\/p>\n<p>\u5728\u8fd9\u91cc\u7684struct sigaction * sa &#061; current-&gt;sigaction &#043; signr &#8211; 1;\u53ef\u4ee5\u770b\u51fasigaction\u6307\u5411\u7684\u662f\u5bf9\u5e94\u89e6\u53d1\u7684\u4fe1\u53f7\u7684sigaction&#xff0c;sigaction\u5728task_struct\u7ed3\u6784\u4f53\u91cc\u9762\u5b9a\u4e49\u7684\u662f\u4e00\u4e2a\u6570\u7ec4&#xff1a;struct sigaction sigaction[32]; \/\/ \u4fe1\u53f7\u6267\u884c\u5c5e\u6027\u7ed3\u6784&#xff0c;\u5bf9\u5e94\u4fe1\u53f7\u5c06\u8981\u6267\u884c\u7684\u64cd\u4f5c\u548c\u6807\u5fd7\u4fe1\u606f<\/p>\n<p>#define SIG_DFL        ((void (*)(int))0)    \/* default signal handling *\/  \/\/ \u9ed8\u8ba4\u7684\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f&#xff08;\u4fe1\u53f7\u53e5\u67c4&#xff09;<br \/>\n#define SIG_IGN        ((void (*)(int))1)    \/* ignore signal *\/            \/\/ \u5ffd\u7565\u4fe1\u53f7\u7684\u5904\u7406\u7a0b\u5e8f<\/p>\n<ul>\n<li>\n<p>\u5bf9\u4e8esa_handler&#xff0c;\u5982\u679c\u662f\u53ef\u5ffd\u7565\u7684\u5c31\u76f4\u63a5\u8fd4\u56de&#xff0c;\u8bf4\u660e\u6ca1\u6709\u4ec0\u4e48\u9700\u8981\u505a\u7684<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u662fsa_handler\u662f\u9ed8\u8ba4&#xff0c;\u90a3\u4e48\u5c31\u4f1a\u5206\u60c5\u51b5\u8ba8\u8bba&#xff1a;\u5982\u679c\u662f\u6536\u5230\u4e86SIGCHLD\u90a3\u4e48\u4e5f\u4ec0\u4e48\u90fd\u4e0d\u505a\u76f4\u63a5\u9000\u51fa\u3002\u5982\u679c\u662f\u5176\u4ed6\u4fe1\u53f7\u90a3\u4e48\u5c31\u76f4\u63a5\u7ec8\u6b62\u8fdb\u7a0b\u3002<\/p>\n<\/li>\n<\/ul>\n<p>POSIX \u6807\u51c6\u4e3a\u6bcf\u4e2a\u4fe1\u53f7\u89c4\u5b9a\u4e86\u9ed8\u8ba4\u884c\u4e3a\u3002\u7edd\u5927\u591a\u6570\u4fe1\u53f7\u7684\u9ed8\u8ba4\u884c\u4e3a\u90fd\u662f \u201c\u7ec8\u6b62\u8fdb\u7a0b&#xff08;Terminate&#xff09;\u201d&#xff0c;\u4f46\u6709\u51e0\u4e2a\u7279\u6b8a\u4fe1\u53f7\u9ed8\u8ba4\u662f \u201c\u5ffd\u7565&#xff08;Ignore&#xff09;\u201d&#xff0c;\u5176\u4e2d\u6700\u91cd\u8981\u7684\u5c31\u662f SIGCHLD\u3002\u5728\u8fd9\u91cc\u4f20\u5165 1 &lt;&lt; (signr-1)&#xff08;\u5373\u4fe1\u53f7\u7f16\u53f7\u5bf9\u5e94\u7684\u4f4d\u63a9\u7801&#xff09;&#xff0c;\u662f\u4e3a\u4e86\u544a\u8bc9\u7236\u8fdb\u7a0b&#xff08;\u901a\u8fc7 wait() \u7cfb\u7edf\u8c03\u7528&#xff09;&#xff1a;\u8be5\u5b50\u8fdb\u7a0b\u4e0d\u662f\u6b63\u5e38\u9000\u51fa&#xff0c;\u800c\u662f\u56e0\u4e3a\u6536\u5230\u4e86\u67d0\u4e2a\u672a\u6355\u83b7\u7684\u4fe1\u53f7\u800c\u7ec8\u6b62\u7684\u3002<\/p>\n<h3 id=\"\u4fee\u6539\u7528\u6237\u6001\u6267\u884c\u6d41\">\u4fee\u6539\u7528\u6237\u6001\u6267\u884c\u6d41<\/h3>\n<p>    if (sa-&gt;sa_flags &amp; SA_ONESHOT)<br \/>\n        sa-&gt;sa_handler &#061; NULL;<br \/>\n    *(&amp;eip) &#061; sa_handler;\/\/ \u5c06\u7528\u6237\u8c03\u7528\u7cfb\u7edf\u8c03\u7528\u7684\u4ee3\u7801\u6307\u9488 eip \u6307\u5411\u8be5\u4fe1\u53f7\u5904\u7406\u53e5\u67c4\u3002<br \/>\n    longs &#061; (sa-&gt;sa_flags &amp; SA_NOMASK)?7:8;<br \/>\n    *(&amp;esp) -&#061; longs;<br \/>\n    verify_area(esp,longs*4);<\/p>\n<p>\u8fd9\u91cc\u5148\u662f\u5224\u65ad\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u662f\u5426\u662f\u4e00\u6b21\u6027\u7684&#xff0c;\u5982\u679c\u662f\u4e00\u6b21\u6027\u7684\u5c31\u4f1a\u628a\u8fd9\u4e2a\u4fe1\u53f7\u5904\u7406\u53e5\u67c4\u7f6e\u7a7a<\/p>\n<p>\u7136\u540e\u5c06\u7528\u6237\u7684eip\u6307\u9488\u6307\u5411\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f&#xff0c;\u5e76\u4e14\u5728\u7528\u6237\u6808\u4e2d\u4e3a\u8fd9\u5757\u7a0b\u5e8f\u5206\u914d\u5806\u6808\u7a7a\u95f4&#xff0c;\u8fd9\u91cc\u53ef\u4ee5\u770b\u51fa\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f\u662f\u8fd0\u884c\u5728\u7528\u6237\u6001\u7a7a\u95f4\u7684&#xff0c;\u5728\u51fd\u6570\u7ed3\u675f\u540e\u5c31\u4f1a\u53bb\u6267\u884c\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f<\/p>\n<p>\u5982\u679c\u4f7f\u7528\u4e86SA_NOMASK\u5219\u8868\u793a\u5728\u8fdb\u884c\u5f53\u524d\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f\u65f6\u5019\u8be5\u4fe1\u53f7\u4e0d\u4f1a\u88ab\u963b\u585e&#xff0c;\u9ed8\u8ba4\u662f\u4f1a\u88ab\u963b\u585e\u7684<\/p>\n<p>\/\/ \u5728\u7528\u6237\u5806\u6808\u4e2d\u4ece\u4e0b\u5230\u4e0a\u5b58\u653e sa_restorer, \u4fe1\u53f7 signr, \u5c4f\u853d\u7801 blocked(\u5982\u679c SA_NOMASK \u7f6e\u4f4d),<br \/>\n    \/\/ eax, ecx, edx, eflags \u548c\u7528\u6237\u7a0b\u5e8f\u539f\u4ee3\u7801\u6307\u9488<br \/>\n    tmp_esp&#061;esp;<br \/>\n    put_fs_long((long) sa-&gt;sa_restorer,tmp_esp&#043;&#043;);<br \/>\n    put_fs_long(signr,tmp_esp&#043;&#043;);<br \/>\n    if (!(sa-&gt;sa_flags &amp; SA_NOMASK))<br \/>\n        put_fs_long(current-&gt;blocked,tmp_esp&#043;&#043;);<br \/>\n    put_fs_long(eax,tmp_esp&#043;&#043;);<br \/>\n    put_fs_long(ecx,tmp_esp&#043;&#043;);<br \/>\n    put_fs_long(edx,tmp_esp&#043;&#043;);<br \/>\n    put_fs_long(eflags,tmp_esp&#043;&#043;);<br \/>\n    put_fs_long(old_eip,tmp_esp&#043;&#043;);<br \/>\n    current-&gt;blocked |&#061; sa-&gt;sa_mask;<\/p>\n<p>\u63a5\u7740\u5c31\u4f1a\u53bb\u8bbe\u7f6e\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u7684\u6808\u7ed3\u6784&#xff0c;\u653e\u5165\u5404\u79cd\u5bc4\u5b58\u5668\u4fe1\u606f\u548c\u72b6\u6001\u5bc4\u5b58\u5668&#xff0c;\u4ee5\u53ca\u539f\u672c\u7528\u6237\u7a0b\u5e8f\u7684\u4e2d\u65ad\u6307\u9488<\/p>\n<p>sa_restorer\u662f\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f\u7ed3\u675f\u4e4b\u540e\u8df3\u8f6c\u5230\u6267\u884c\u7684\u7a0b\u5e8f&#xff0c;sa_restorer \u91cc\u901a\u5e38\u53ea\u6709\u4e00\u6761\u6838\u5fc3\u6307\u4ee4\u2014\u2014\u89e6\u53d1 int 0x80&#xff0c;\u8c03\u7528 sys_sigreturn\u3002<\/p>\n<h2 id=\"sys_signal\">sys_signal<\/h2>\n<p>\/\/ signal()\u7cfb\u7edf\u8c03\u7528\u3002\u7c7b\u4f3c\u4e8e sigaction()\u3002\u4e3a\u6307\u5b9a\u7684\u4fe1\u53f7\u5b89\u88c5\u65b0\u7684\u4fe1\u53f7\u53e5\u67c4(\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f)\u3002<br \/>\n \/\/ \u4fe1\u53f7\u53e5\u67c4\u53ef\u4ee5\u662f\u7528\u6237\u6307\u5b9a\u7684\u51fd\u6570&#xff0c;\u4e5f\u53ef\u4ee5\u662f SIG_DFL&#xff08;\u9ed8\u8ba4\u53e5\u67c4&#xff09;\u6216 SIG_IGN&#xff08;\u5ffd\u7565&#xff09;\u3002<br \/>\n \/\/ \u53c2\u6570 signum &#8211;\u6307\u5b9a\u7684\u4fe1\u53f7&#xff1b;handler &#8212; \u6307\u5b9a\u7684\u53e5\u67c4&#xff1b;restorer &#8212; [??]<br \/>\n \/\/ \u51fd\u6570\u8fd4\u56de\u539f\u4fe1\u53f7\u53e5\u67c4\u3002<br \/>\n \/**<br \/>\n  * &#064;brief \u4e3a\u6307\u5b9a\u7684\u4fe1\u53f7\u5b89\u88c5\u65b0\u7684\u4fe1\u53f7\u53e5\u67c4&#xff08;\u4fe1\u53f7\u5904\u7406\u7a0b\u5e8f&#xff09;<br \/>\n  *<br \/>\n  * &#064;param signum \u4fe1\u53f7\u503c&#xff08;\u6307\u5b9a\u7684\u4fe1\u53f7&#xff09;<br \/>\n  * &#064;param handler \u6307\u5b9a\u7684\u53e5\u67c4<br \/>\n  * &#064;param restorer \u6307\u5b9a\u7684\u6062\u590d\u53e5\u67c4<br \/>\n  * &#064;return int \u8fd4\u56de\u5f53\u524d\u4efb\u52a1\u7684\u6307\u5b9a\u4fe1\u53f7\u5904\u7406\u53e5\u67c4&#xff08;&#xff1f;&#xff1f;\u8fd4\u56de\u539f\u4fe1\u53f7\u53e5\u67c4&#xff09;<br \/>\n  *\/<br \/>\nint sys_signal(int signum, long handler, long restorer)<br \/>\n{<br \/>\n    struct sigaction tmp;<\/p>\n<p>    if (signum&lt;1 || signum&gt;32 || signum&#061;&#061;SIGKILL)<br \/>\n        return -1;<br \/>\n    tmp.sa_handler &#061; (void (*)(int)) handler;        \/\/ \u6307\u5b9a\u7684\u4fe1\u53f7\u5904\u7406\u53e5\u67c4<br \/>\n    tmp.sa_mask &#061; 0;                                \/\/ \u6267\u884c\u65f6\u7684\u4fe1\u53f7\u5c4f\u853d\u7801<br \/>\n    tmp.sa_flags &#061; SA_ONESHOT | SA_NOMASK;            \/\/ \u8be5\u53e5\u67c4\u53ea\u4f7f\u7528 1 \u6b21\u540e\u5c31\u6062\u590d\u5230\u9ed8\u8ba4\u503c<br \/>\n    tmp.sa_restorer &#061; (void (*)(void)) restorer;    \/\/ \u6307\u5b9a\u4fe1\u53f7\u6062\u590d\u53e5\u67c4<br \/>\n    handler &#061; (long) current-&gt;sigaction[signum-1].sa_handler;<br \/>\n    current-&gt;sigaction[signum-1] &#061; tmp;<br \/>\n    return handler;<br \/>\n}<\/p>\n<p>sys_signal\u4e3a\u6307\u5b9a\u4fe1\u53f7\u5b89\u88c5\u65b0\u7684\u4fe1\u53f7\u5904\u7406\u51fd\u6570&#xff0c;\u5e76\u4e14\u8fd4\u56de\u8bbe\u7f6e\u524d\u7684\u4fe1\u53f7\u5904\u7406\u53e5\u67c4<\/p>\n<h2 id=\"sys_sigaction\">sys_sigaction<\/h2>\n<p>\u6539\u53d8\u4e00\u4e2a\u8fdb\u7a0b\u5728\u53d7\u5230\u4fe1\u53f7\u65f6\u7684\u64cd\u4f5c<\/p>\n<p>**<br \/>\n * &#064;brief \u6539\u53d8\u8fdb\u7a0b\u5728\u6536\u5230\u4e00\u4e2a\u4fe1\u53f7\u65f6\u7684\u64cd\u4f5c<br \/>\n *<br \/>\n * &#064;param signum \u9664\u4e86 SIGKILL \u4ee5\u5916\u7684\u4efb\u4f55\u4fe1\u53f7<br \/>\n * &#064;param action \u65b0\u7684\u4fe1\u53f7\u64cd\u4f5c\u7ed3\u6784\u4f53<br \/>\n * &#064;param oldaction \u4fdd\u5b58\u539f\u59cbaction<br \/>\n * &#064;return int success-0, fail-1<br \/>\n *\/<br \/>\nint sys_sigaction(int signum, const struct sigaction * action,<br \/>\n    struct sigaction * oldaction)<br \/>\n{<br \/>\n    struct sigaction tmp;<\/p>\n<p>    if (signum&lt;1 || signum&gt;32 || signum&#061;&#061;SIGKILL)<br \/>\n        return -1;<br \/>\n    tmp &#061; current-&gt;sigaction[signum-1];<br \/>\n    get_new((char *) action,<br \/>\n        (char *) (signum-1&#043;current-&gt;sigaction));<br \/>\n    if (oldaction)<br \/>\n        save_old((char *) &amp;tmp,(char *) oldaction);<br \/>\n    if (current-&gt;sigaction[signum-1].sa_flags &amp; SA_NOMASK)<br \/>\n        current-&gt;sigaction[signum-1].sa_mask &#061; 0;<br \/>\n    else<br \/>\n        current-&gt;sigaction[signum-1].sa_mask |&#061; (1&lt;&lt;(signum-1));<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u5c06\u65b0\u7684action\u66ff\u6362\u8c03\u539f\u6765task_struct\u4e2d\u5bf9\u5e94\u4fe1\u53f7\u7684sigaction<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sigaction\u7ed3\u6784\u4f53\/\/ \u4e0b\u9762\u662f sigaction \u7684\u6570\u636e\u7ed3\u6784\u3002 \/\/ sa_handler \u662f\u5bf9\u5e94\u67d0\u4fe1\u53f7\u6307\u5b9a\u8981\u91c7\u53d6\u7684\u884c\u52a8\u3002\u53ef\u4ee5\u662f\u4e0a\u9762\u7684 SIG_DFL&#xff0c;\u6216\u8005\u662f SIG_IGN \u6765\u5ffd\u7565 \/\/ \u8be5\u4fe1\u53f7&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u6307\u5411\u5904\u7406\u8be5\u4fe1\u53f7\u7684\u4e00\u4e2a\u6307\u9488\u3002 \/\/ sa_mask \u7ed9\u51fa\u4e86\u5bf9\u4fe1\u53f7\u7684\u5c4f\u853d\u7801&#xff0c;\u5728\u4fe1\u53f7\u7a0b\u5e8f\u6267\u884c\u65f6\u5c06\u963b\u585e\u5bf9\u8fd9\u4e9b\u4fe1\u53f7\u7684\u5904\u7406\u3002 \/\/ sa_flags \u6307\u5b9a\u6539\u53d8\u4fe1\u53f7\u5904\u7406\u8fc7\u7a0b\u7684\u4fe1\u53f7\u96c6\u3002\u5b83\u662f\u7531 37-39 \u884c\u7684\u4f4d\u6807\u5fd7\u5b9a\u4e49\u7684\u3002 \/\/ \u53e6\u5916&amp;#x<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9499,9099,58,2710],"topic":[],"class_list":["post-84801","post","type-post","status-publish","format-standard","hentry","category-server","tag-9499","tag-9099","tag-linux","tag-2710"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570 - \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\/84801.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"sigaction\u7ed3\u6784\u4f53\/\/ \u4e0b\u9762\u662f sigaction \u7684\u6570\u636e\u7ed3\u6784\u3002 \/\/ sa_handler \u662f\u5bf9\u5e94\u67d0\u4fe1\u53f7\u6307\u5b9a\u8981\u91c7\u53d6\u7684\u884c\u52a8\u3002\u53ef\u4ee5\u662f\u4e0a\u9762\u7684 SIG_DFL&#xff0c;\u6216\u8005\u662f SIG_IGN \u6765\u5ffd\u7565 \/\/ \u8be5\u4fe1\u53f7&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u6307\u5411\u5904\u7406\u8be5\u4fe1\u53f7\u7684\u4e00\u4e2a\u6307\u9488\u3002 \/\/ sa_mask \u7ed9\u51fa\u4e86\u5bf9\u4fe1\u53f7\u7684\u5c4f\u853d\u7801&#xff0c;\u5728\u4fe1\u53f7\u7a0b\u5e8f\u6267\u884c\u65f6\u5c06\u963b\u585e\u5bf9\u8fd9\u4e9b\u4fe1\u53f7\u7684\u5904\u7406\u3002 \/\/ sa_flags \u6307\u5b9a\u6539\u53d8\u4fe1\u53f7\u5904\u7406\u8fc7\u7a0b\u7684\u4fe1\u53f7\u96c6\u3002\u5b83\u662f\u7531 37-39 \u884c\u7684\u4f4d\u6807\u5fd7\u5b9a\u4e49\u7684\u3002 \/\/ \u53e6\u5916&amp;#x\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/84801.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-26T10:17:56+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84801.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/84801.html\",\"name\":\"Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-26T10:17:56+00:00\",\"dateModified\":\"2026-07-26T10:17:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/84801.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/84801.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84801.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570\"}]},{\"@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\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570 - \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\/84801.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"sigaction\u7ed3\u6784\u4f53\/\/ \u4e0b\u9762\u662f sigaction \u7684\u6570\u636e\u7ed3\u6784\u3002 \/\/ sa_handler \u662f\u5bf9\u5e94\u67d0\u4fe1\u53f7\u6307\u5b9a\u8981\u91c7\u53d6\u7684\u884c\u52a8\u3002\u53ef\u4ee5\u662f\u4e0a\u9762\u7684 SIG_DFL&#xff0c;\u6216\u8005\u662f SIG_IGN \u6765\u5ffd\u7565 \/\/ \u8be5\u4fe1\u53f7&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u6307\u5411\u5904\u7406\u8be5\u4fe1\u53f7\u7684\u4e00\u4e2a\u6307\u9488\u3002 \/\/ sa_mask \u7ed9\u51fa\u4e86\u5bf9\u4fe1\u53f7\u7684\u5c4f\u853d\u7801&#xff0c;\u5728\u4fe1\u53f7\u7a0b\u5e8f\u6267\u884c\u65f6\u5c06\u963b\u585e\u5bf9\u8fd9\u4e9b\u4fe1\u53f7\u7684\u5904\u7406\u3002 \/\/ sa_flags \u6307\u5b9a\u6539\u53d8\u4fe1\u53f7\u5904\u7406\u8fc7\u7a0b\u7684\u4fe1\u53f7\u96c6\u3002\u5b83\u662f\u7531 37-39 \u884c\u7684\u4f4d\u6807\u5fd7\u5b9a\u4e49\u7684\u3002 \/\/ \u53e6\u5916&amp;#x","og_url":"https:\/\/www.wsisp.com\/helps\/84801.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-26T10:17:56+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/84801.html","url":"https:\/\/www.wsisp.com\/helps\/84801.html","name":"Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-26T10:17:56+00:00","dateModified":"2026-07-26T10:17:56+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/84801.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/84801.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/84801.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u5185\u6838-\u5185\u6838\u4fe1\u53f7\u5904\u7406\u51fd\u6570"}]},{"@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\/84801","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=84801"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84801\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=84801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=84801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=84801"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=84801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}