{"id":124758,"date":"2026-11-19T12:33:10","date_gmt":"2026-11-19T04:33:10","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/124758.html"},"modified":"2026-11-19T12:33:10","modified_gmt":"2026-11-19T04:33:10","slug":"%e3%80%90linux%e7%bd%91%e7%bb%9c%e3%80%91tcp-%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%b9%b6%e5%8f%91%e5%a4%84%e7%90%86%e5%a4%9a%e5%ae%a2%e6%88%b7%e7%ab%af%ef%bc%9a%e4%bb%8e-fork-%e5%88%86%e5%8f%91%e5%88%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/124758.html","title":{"rendered":"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p>\u5f88\u591a\u5199\u8fc7 TCP \u670d\u52a1\u5668\u7684\u4eba\u7b2c\u4e00\u6b21\u538b\u6d4b\u90fd\u4f1a\u649e\u4e0a\u540c\u4e00\u5835\u5899&#xff1a;\u7b2c\u4e00\u4e2a\u5ba2\u6237\u7aef\u4e0d\u9000\u51fa&#xff0c;\u540e\u9762\u6240\u6709\u8fde\u63a5\u5c31\u4e00\u76f4\u5361\u5728 backlog \u91cc\u6392\u961f&#xff0c;\u8868\u73b0\u662f connect \u6210\u529f\u5374\u8fdf\u8fdf\u8bfb\u4e0d\u5230\u54cd\u5e94\u3002\u95ee\u9898\u4e0d\u5728\u5185\u6838&#xff0c;\u800c\u5728\u7a0b\u5e8f\u53ea\u5199\u4e86\u4e00\u4e2a\u987a\u5e8f accept \u7684\u5faa\u73af\u3002<\/p>\n<p>\u5e38\u89c4\u505a\u6cd5\u662f\u300c\u8bfb\u5b8c\u4e00\u4e2a\u518d\u6536\u4e0b\u4e00\u4e2a\u300d&#xff0c;\u5b83\u5728 demo \u91cc\u6ca1\u95ee\u9898&#xff0c;\u4e00\u65e6\u5ba2\u6237\u7aef\u6162\u3001\u8fde\u63a5\u591a&#xff0c;\u4e32\u884c\u7ed3\u6784\u5c31\u5f7b\u5e95\u66b4\u9732&#xff1a;\u670d\u52a1\u4e00\u4e2a\u8fde\u63a5\u7684\u65f6\u95f4\u7b49\u4e8e\u6240\u6709\u8fde\u63a5\u7684\u603b\u7b49\u5f85\u65f6\u95f4&#xff0c;\u52a0\u8d85\u65f6\u4e5f\u6551\u4e0d\u4e86\u541e\u5410\u3002\u591a\u7ebf\u7a0b\u867d\u7136\u80fd\u89e3\u51b3&#xff0c;\u4f46\u7ebf\u7a0b\u6808\u548c\u9501\u7684\u6210\u672c\u5bf9\u7b80\u5355 echo \u670d\u52a1\u53c8\u8fc7\u91cd\u3002<\/p>\n<p>\u672c\u6587\u5206\u4eab\u4e00\u5957\u4ece\u6700\u5c0f\u53ef\u7528\u5230\u751f\u4ea7\u53ef\u4f9d\u8d56\u7684\u5e76\u53d1\u65b9\u6848&#xff1a;fork \u5206\u53d1 &#043; SIGCHLD \u5faa\u73af\u56de\u6536 &#043; \u53cc\u91cd fork \u5f7b\u5e95\u89e3\u8026&#xff0c;\u53ef\u76f4\u63a5\u843d\u5730\u3002<\/p>\n<h3>\u4e00\u3001\u4e32\u884c\u963b\u585e\u6a21\u578b\u4e3a\u4f55\u6491\u4e0d\u8d77\u591a\u5ba2\u6237\u7aef<\/h3>\n<p>\u5148\u770b\u6e05\u6839\u56e0&#xff1a;\u4e00\u53f0\u53ea\u4f1a\u987a\u5e8f accept \u7684\u670d\u52a1\u5668&#xff0c;\u74f6\u9888\u5230\u5e95\u51fa\u5728\u54ea\u91cc&#xff1a;<\/p>\n<ul>\n<li>accept \u4e0e read \u4e32\u5728\u540c\u4e00\u8fdb\u7a0b&#xff1a;\u7236\u5faa\u73af\u963b\u585e\u5728\u67d0\u4e00\u4e2a\u5df2\u8fde\u63a5 fd \u7684 recv \u4e0a&#xff0c;\u65b0\u7684\u8fde\u63a5\u8bf7\u6c42\u53ea\u80fd\u5806\u5728\u5185\u6838\u961f\u5217\u91cc&#xff0c;\u8d85\u8fc7 backlog \u540e\u88ab\u5185\u6838\u76f4\u63a5\u4e22\u5f03\u3002<\/li>\n<li>\u6162\u5ba2\u6237\u7aef\u653e\u5927\u5ef6\u8fdf&#xff1a;\u4e00\u4e2a\u4e0d\u53d1\u6570\u636e\u7684\u5ba2\u6237\u7aef\u4f1a\u628a\u6574\u4e2a\u8fdb\u7a0b\u6302\u4f4f&#xff0c;\u5176\u4ed6\u6b63\u5e38\u5ba2\u6237\u7aef\u770b\u5230\u7684\u662f\u300c\u8fde\u63a5\u6210\u529f\u4f46\u65e0\u54cd\u5e94\u300d\u3002<\/li>\n<li>\u5355\u70b9\u5d29\u6e83&#xff1a;\u4efb\u4f55\u4e00\u6b21 read \u8fd4\u56de\u9519\u8bef\u5bfc\u81f4 break&#xff0c;\u670d\u52a1\u76f4\u63a5\u505c\u6446&#xff0c;\u65e0\u6cd5\u53ea\u5f71\u54cd\u5355\u4e2a\u8fde\u63a5\u3002<\/li>\n<\/ul>\n<p>\u4e09\u79cd\u7ed3\u6784\u7684\u4ee3\u4ef7\u5bf9\u6bd4\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u6a21\u578baccept \u884c\u4e3a\u6162\u5ba2\u6237\u7aef\u5f71\u54cd\u6269\u5c55\u4e0a\u9650<\/tr>\n<tbody>\n<tr>\n<td>\u5355\u8fdb\u7a0b\u4e32\u884c<\/td>\n<td>\u670d\u52a1\u5b8c\u4e00\u4e2a\u624d\u6536\u4e0b\u4e00\u4e2a<\/td>\n<td>\u5168\u90e8\u6392\u961f\u8d85\u65f6<\/td>\n<td>1 \u4e2a\u8fde\u63a5<\/td>\n<\/tr>\n<tr>\n<td>fork \u5b50\u8fdb\u7a0b<\/td>\n<td>\u7236\u8fdb\u7a0b\u7acb\u5373\u56de\u5230 accept<\/td>\n<td>\u4e92\u4e0d\u963b\u585e<\/td>\n<td>\u8fdb\u7a0b\u6570\u9650\u5236<\/td>\n<\/tr>\n<tr>\n<td>IO \u591a\u8def\u590d\u7528<\/td>\n<td>\u5355\u7ebf\u7a0b\u8f6e\u8be2\u5c31\u7eea fd<\/td>\n<td>\u4f9d\u8d56\u4e8b\u4ef6\u5faa\u73af<\/td>\n<td>\u6570\u5343 fd<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>**\u6838\u5fc3\u7ed3\u8bba&#xff1a;**\u5e76\u53d1\u7684\u7b2c\u4e00\u6b65\u4e0d\u662f\u8ba9\u5904\u7406\u53d8\u5feb&#xff0c;\u800c\u662f\u8ba9 accept \u6c38\u8fdc\u4e0d\u88ab\u4e1a\u52a1\u903b\u8f91\u62d6\u4f4f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261119043305-6afe7c017bfb7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u4e8c\u3001fork \u5206\u53d1&#xff1a;\u7236\u8fdb\u7a0b\u53ea\u76d1\u542c\u5b50\u8fdb\u7a0b\u4e13\u670d\u52a1<\/h3>\n<p>\u628a\u804c\u8d23\u5207\u5f00\u53ea\u7528\u4e09\u884c\u903b\u8f91&#xff1a;\u7236\u8fdb\u7a0b\u53ea accept&#xff0c;\u5b50\u8fdb\u7a0b\u53ea\u5904\u7406\u8fde\u63a5\u3002<\/p>\n<p>\u4e0b\u9762\u8fd9\u6bb5\u662f fork \u7248 TCP \u670d\u52a1\u5668\u7684\u4e3b\u5faa\u73af\u9aa8\u67b6&#xff0c;\u9002\u914d Linux &#043; glibc&#xff0c;\u7528 gcc -o srv srv.c \u5373\u53ef\u7f16\u8bd1&#xff1a;<\/p>\n<p><span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> cfd <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">accept<\/span><span class=\"token punctuation\">(<\/span>lfd<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">&amp;<\/span>cli<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>len<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>cfd <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">continue<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token class-name\">pid_t<\/span> pid <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">fork<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>pid <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>            <span class=\"token comment\">\/* \u5b50\u8fdb\u7a0b&#xff1a;\u5173\u6389\u76d1\u542c fd&#xff0c;\u4e13\u5fc3\u670d\u52a1\u8fd9\u4e2a\u5ba2\u6237\u7aef *\/<\/span><br \/>\n        <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>lfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">handle<\/span><span class=\"token punctuation\">(<\/span>cfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>           <span class=\"token comment\">\/* \u8bfb\u5199\u56de\u663e&#xff0c;\u4e1a\u52a1\u903b\u8f91\u5168\u5728\u8fd9\u91cc *\/<\/span><br \/>\n        <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>cfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">_exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>              <span class=\"token comment\">\/* \u7528 _exit \u907f\u514d\u51b2\u5237\u7236\u8fdb\u7a0b\u7684 stdio \u7f13\u51b2 *\/<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>cfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                <span class=\"token comment\">\/* \u7236\u8fdb\u7a0b&#xff1a;\u5fc5\u987b\u5173\u6389\u5df2\u8fde\u63a5 fd&#xff0c;\u5426\u5219\u6cc4\u6f0f *\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u7236\u8fdb\u7a0b\u5173 cfd\u3001\u5b50\u8fdb\u7a0b\u5173 lfd&#xff0c;\u8fd9\u662f fork \u5e76\u53d1\u6700\u5bb9\u6613\u6f0f\u6389\u7684\u4e24\u884c&#xff0c;\u6f0f\u6389\u4efb\u610f\u4e00\u884c\u90fd\u4f1a\u8ba9\u8fde\u63a5\u63cf\u8ff0\u7b26\u548c\u76d1\u542c\u5957\u63a5\u5b57\u5728\u591a\u4f59\u8fdb\u7a0b\u91cc\u6ede\u7559\u3002<\/p>\n<ul>\n<li>\u5fc5\u987b _exit&#xff1a;\u5b50\u8fdb\u7a0b\u7ee7\u627f\u4e86\u7236\u8fdb\u7a0b\u7684\u7f13\u51b2\u533a&#xff0c;\u7528 exit() \u4f1a\u91cd\u590d\u5237\u65b0\u672a\u5237\u51fa\u7684\u65e5\u5fd7&#xff0c;\u4ea7\u751f\u91cd\u590d\u8f93\u51fa\u3002<\/li>\n<li>\u7236\u8fdb\u7a0b\u4e0d\u53c2\u4e0e\u8bfb\u5199&#xff1a;\u8fd9\u6837\u5373\u4f7f\u67d0\u4e2a\u5ba2\u6237\u7aef\u963b\u585e&#xff0c;\u4e5f\u53ea\u6302\u4f4f\u5b83\u81ea\u5df1\u7684\u5b50\u8fdb\u7a0b\u3002<\/li>\n<\/ul>\n<p>**\u6838\u5fc3\u7ed3\u8bba&#xff1a;**fork \u7684\u672c\u8d28\u662f\u7528\u8fdb\u7a0b\u9694\u79bb\u6362\u53d6\u5e76\u53d1&#xff0c;accept \u5faa\u73af\u56e0\u6b64\u6c38\u8fdc\u4fdd\u6301\u6d3b\u8dc3\u3002<\/p>\n<h3>\u4e09\u3001\u50f5\u5c38\u8fdb\u7a0b&#xff1a;\u5b50\u8fdb\u7a0b\u9000\u51fa\u540e\u4ecd\u5360\u8fdb\u7a0b\u8868<\/h3>\n<p>\u538b\u6d4b\u8dd1\u5b8c\u540e\u4f1a\u51fa\u73b0\u65b0\u9ebb\u70e6&#xff0c;\u5148\u89e3\u91ca\u5b83\u4ece\u54ea\u6765&#xff1a;<\/p>\n<ul>\n<li>\u9000\u51fa\u672a\u88ab\u6536\u5272&#xff1a;\u5b50\u8fdb\u7a0b _exit \u540e\u5185\u6838\u4fdd\u7559\u5176\u9000\u51fa\u7801\u4e0e\u7edf\u8ba1\u4fe1\u606f&#xff0c;\u7236\u8fdb\u7a0b\u6ca1\u8c03 wait \u5c31\u6ca1\u4eba\u91ca\u653e\u8fd9\u5757 \u8fdb\u7a0b\u8868\u9879\u3002<\/li>\n<li>\u50f5\u5c38\u7684\u5371\u5bb3&#xff1a;\u50f5\u5c38\u4e0d\u5360\u5185\u5b58\u4e0d\u5360 CPU&#xff0c;\u4f46\u5360 PID&#xff0c;\u957f\u671f\u5806\u79ef\u4f1a\u5bfc\u81f4\u7cfb\u7edf PID \u8017\u5c3d&#xff0c;fork \u76f4\u63a5\u8fd4\u56de EAGAIN\u3002<\/li>\n<li>\u4fe1\u53f7\u53ea\u901a\u77e5\u4e0d\u56de\u6536&#xff1a;\u6536\u5230 SIGCHLD \u53ea\u4ee3\u8868\u300c\u6709\u5b69\u5b50\u7ed3\u675f\u4e86\u300d&#xff0c;\u4e0d\u81ea\u52a8\u91ca\u653e&#xff0c;\u5fc5\u987b\u663e\u5f0f\u8c03\u7528 waitpid\u3002<\/li>\n<\/ul>\n<p>\u7528\u4e00\u6761\u547d\u4ee4\u5c31\u80fd\u5728\u673a\u5668\u4e0a\u9a8c\u8bc1&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5217\u51fa\u6240\u6709\u50f5\u5c38\u8fdb\u7a0b&#xff0c;Z \u72b6\u6001\u5373\u50f5\u5c38&#xff0c;PPID \u662f\u5931\u804c\u7684\u7236\u8fdb\u7a0b<\/span><br \/>\n<span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-eo<\/span> stat,pid,ppid,cmd <span class=\"token operator\">|<\/span> <span class=\"token function\">awk<\/span> <span class=\"token string\">&#039;$1 ~ \/^Z\/ {print}&#039;<\/span><\/p>\n<p>\u53ea\u8981 Z \u72b6\u6001\u5237\u5c4f&#xff0c;\u95ee\u9898\u4e00\u5b9a\u51fa\u5728\u7236\u8fdb\u7a0b\u7684\u56de\u6536\u903b\u8f91\u4e0a&#xff0c;\u800c\u4e0d\u662f\u5b50\u8fdb\u7a0b\u672c\u8eab\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261119043306-6afe7c027814e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u56db\u3001SIGCHLD \u56de\u6536&#xff1a;waitpid \u7684\u6b63\u786e\u59ff\u52bf<\/h3>\n<p>\u56de\u6536\u4e0d\u80fd\u9760\u8f6e\u8be2\u6b7b\u7b49&#xff0c;\u6b63\u786e\u505a\u6cd5\u662f\u4fe1\u53f7\u9a71\u52a8 &#043; \u5faa\u73af\u6536\u5272&#xff1a;<\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">on_chld<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> sig<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> saved <span class=\"token operator\">&#061;<\/span> errno<span class=\"token punctuation\">;<\/span>                    <span class=\"token comment\">\/* \u4fe1\u53f7\u5904\u7406\u5fc5\u987b\u4fdd\u5b58\u5e76\u6062\u590d errno *\/<\/span><br \/>\n    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">waitpid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> WNOHANG<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/* \u4e00\u6b21\u6536\u5e72\u51c0\u6240\u6709\u5df2\u9000\u51fa\u5b50\u8fdb\u7a0b *\/<\/span><br \/>\n    errno <span class=\"token operator\">&#061;<\/span> saved<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sigaction<\/span> sa <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\nsa<span class=\"token punctuation\">.<\/span>sa_handler <span class=\"token operator\">&#061;<\/span> on_chld<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">sigemptyset<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>sa<span class=\"token punctuation\">.<\/span>sa_mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nsa<span class=\"token punctuation\">.<\/span>sa_flags <span class=\"token operator\">&#061;<\/span> SA_RESTART <span class=\"token operator\">|<\/span> SA_NOCLDSTOP<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/* SA_RESTART \u8ba9 accept \u4e0d\u88ab\u4e2d\u65ad *\/<\/span><br \/>\n<span class=\"token function\">sigaction<\/span><span class=\"token punctuation\">(<\/span>SIGCHLD<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>sa<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4e00\u6b21 WNOHANG \u5faa\u73af\u6536\u4e00\u6279&#xff0c;\u662f\u907f\u514d\u50f5\u5c38\u5806\u79ef\u7684\u5173\u952e&#xff0c;\u53ea\u8c03\u4e00\u6b21 wait \u4f1a\u5728\u5e76\u53d1\u9000\u51fa\u65f6\u6f0f\u6536\u3002<\/p>\n<ul>\n<li>\u4e0d\u7528 signal()&#xff1a;\u4e0d\u540c libc \u5bf9\u4fe1\u53f7\u8bed\u4e49\u5b9e\u73b0\u4e0d\u4e00&#xff0c;sigaction \u624d\u662f\u53ef\u79fb\u690d\u5199\u6cd5\u3002<\/li>\n<li>\u5ffd\u7565 EINTR&#xff1a;\u5373\u4f7f\u8bbe\u4e86 SA_RESTART&#xff0c;accept \u4ecd\u53ef\u80fd\u8fd4\u56de EINTR&#xff0c;\u4e3b\u5faa\u73af\u8981 continue \u91cd\u8bd5\u3002<\/li>\n<li>handler \u4fdd\u6301\u6781\u7b80&#xff1a;\u53ea\u505a\u56de\u6536&#xff0c;\u65e5\u5fd7\u548c\u4e1a\u52a1\u4e00\u5f8b\u653e\u56de\u4e3b\u6d41\u7a0b\u3002<\/li>\n<\/ul>\n<p>**\u6838\u5fc3\u7ed3\u8bba&#xff1a;**SIGCHLD \u8d1f\u8d23\u63d0\u9192&#xff0c;waitpid \u5faa\u73af\u8d1f\u8d23\u771f\u6b63\u91ca\u653e&#xff0c;\u4e24\u8005\u7f3a\u4e00\u4e0d\u53ef\u3002<\/p>\n<h3>\u4e94\u3001\u53cc\u91cd fork&#xff1a;\u5b59\u5b50\u8fdb\u7a0b\u4ea4\u7ed9 init \u6536\u517b<\/h3>\n<p>\u5373\u4fbf\u56de\u6536\u5199\u5bf9\u4e86&#xff0c;\u4ecd\u6709\u4e00\u79cd\u573a\u666f\u4f1a\u95ea\u73b0\u50f5\u5c38&#xff1a;\u4fe1\u53f7\u5904\u7406\u4e0e\u5b50\u8fdb\u7a0b\u9000\u51fa\u7684\u7ade\u4e89\u7a97\u53e3&#xff0c;\u53cc\u91cd fork \u6b63\u662f\u4e3a\u5173\u6389\u8fd9\u4e2a\u7a97\u53e3&#xff1a;<\/p>\n<p><span class=\"token class-name\">pid_t<\/span> pid <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">fork<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>pid <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>                 <span class=\"token comment\">\/* \u4e2d\u95f4\u5b50\u8fdb\u7a0b *\/<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">fork<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>          <span class=\"token comment\">\/* \u5b59\u5b50\u8fdb\u7a0b&#xff1a;\u771f\u6b63\u5e72\u6d3b\u7684\u90a3\u4e2a *\/<\/span><br \/>\n        <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>lfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">handle<\/span><span class=\"token punctuation\">(<\/span>cfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>cfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token function\">_exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                   <span class=\"token comment\">\/* \u4e2d\u95f4\u8fdb\u7a0b\u7acb\u523b\u9000\u51fa&#xff0c;\u8131\u79bb\u7236\u8fdb\u7a0b\u63a7\u5236 *\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>cfd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">waitpid<\/span><span class=\"token punctuation\">(<\/span>pid<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>          <span class=\"token comment\">\/* \u7236\u8fdb\u7a0b\u540c\u6b65\u6536\u5272\u4e2d\u95f4\u8fdb\u7a0b&#xff0c;\u7edd\u4e0d\u6b8b\u7559 *\/<\/span><\/p>\n<p>\u6d41\u7a0b\u94fe\u8def\u53ef\u4ee5\u8bb0\u6210&#xff1a;<\/p>\n<p>accept \u2192 fork \u4e2d\u95f4\u8fdb\u7a0b \u2192 fork \u5b59\u8fdb\u7a0b \u2192 \u4e2d\u95f4\u8fdb\u7a0b _exit \u2192 init\/subreaper \u6536\u517b\u5b59\u8fdb\u7a0b<\/p>\n<ul>\n<li>\u7236\u8fdb\u7a0b\u53ea\u7b49\u4e2d\u95f4\u8fdb\u7a0b&#xff1a;\u4e2d\u95f4\u8fdb\u7a0b\u5bff\u547d\u6781\u77ed&#xff0c;waitpid \u7acb\u5373\u8fd4\u56de&#xff0c;\u4e0d\u5360\u7528\u4e1a\u52a1\u65f6\u95f4\u3002<\/li>\n<li>\u5b59\u8fdb\u7a0b\u6210\u4e3a\u5b64\u513f&#xff1a;\u7531 init&#xff08;\u5bb9\u5668\u5185\u4e3a PID 1 \u6216\u6307\u5b9a\u7684 subreaper&#xff09;\u81ea\u52a8 wait&#xff0c;\u670d\u52a1\u5668\u5f7b\u5e95\u4e0d\u9700\u8981\u4e3a\u5b83\u5904\u7406\u4fe1\u53f7\u3002<\/li>\n<li>\u8fdb\u7a0b\u7ec4\u88ab\u5207\u65ad&#xff1a;\u5b59\u8fdb\u7a0b\u4e0d\u968f\u670d\u52a1\u5668\u9000\u51fa&#xff0c;\u9002\u5408\u9700\u8981\u5728\u8fde\u63a5\u7ed3\u675f\u540e\u7ee7\u7eed\u8dd1\u6536\u5c3e\u4efb\u52a1\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n<p>\u82e5\u4e0d\u60f3\u6539\u4ee3\u7801&#xff0c;\u4e5f\u53ef\u7528 prctl(PR_SET_CHILD_SUBREAPER, 1) \u8ba9\u672c\u8fdb\u7a0b\u81ea\u52a8\u4ee3\u7ba1\u5b64\u513f&#xff0c;\u6548\u679c\u7b49\u4ef7\u3002<\/p>\n<p>**\u6838\u5fc3\u7ed3\u8bba&#xff1a;**\u53cc\u91cd fork \u628a\u300c\u8c01\u6765 wait\u300d\u8fd9\u4ef6\u4e8b\u5916\u5305\u7ed9 init&#xff0c;\u4ece\u7ed3\u6784\u4e0a\u6d88\u706d\u50f5\u5c38\u3002<\/p>\n<h3>\u516d\u3001\u5e76\u53d1\u6a21\u578b\u9009\u578b\u4e0e\u50f5\u5c38\u8fdb\u7a0b\u7ebf\u4e0a\u6392\u9519<\/h3>\n<p>\u65b9\u6848\u843d\u5730\u524d\u5148\u505a\u4e00\u6b21\u6a2a\u5411\u5bf9\u6bd4&#xff0c;\u907f\u514d\u628a fork \u7528\u5728\u4e0d\u5408\u9002\u7684\u573a\u666f&#xff1a;<\/p>\n<table>\n<tr>\u65b9\u6848\u4e0a\u4e0b\u6587\u5207\u6362\u5f00\u9500\u7f16\u7a0b\u590d\u6742\u5ea6\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>fork \u6bcf\u8fde\u63a5\u4e00\u8fdb\u7a0b<\/td>\n<td>\u9ad8&#xff08;\u8fdb\u7a0b\u7ea7&#xff09;<\/td>\n<td>\u4f4e&#xff0c;\u9694\u79bb\u6027\u597d<\/td>\n<td>\u8fde\u63a5\u6570\u5c11\u3001\u903b\u8f91\u91cd\u3001\u9700\u5d29\u6e83\u9694\u79bb<\/td>\n<\/tr>\n<tr>\n<td>\u7ebf\u7a0b\u6c60<\/td>\n<td>\u4e2d&#xff08;\u7ebf\u7a0b\u7ea7&#xff09;<\/td>\n<td>\u4e2d&#xff0c;\u9700\u5904\u7406\u5171\u4eab\u72b6\u6001<\/td>\n<td>\u8fde\u63a5\u6570\u4e2d\u7b49\u3001\u6709\u5171\u4eab\u7f13\u5b58<\/td>\n<\/tr>\n<tr>\n<td>epoll \u4e8b\u4ef6\u9a71\u52a8<\/td>\n<td>\u6700\u4f4e<\/td>\n<td>\u9ad8&#xff0c;\u9700\u975e\u963b\u585e\u72b6\u6001\u673a<\/td>\n<td>\u9ad8\u5e76\u53d1\u77ed\u8fde\u63a5\u3001C10K \u4ee5\u4e0a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7ebf\u4e0a\u53d1\u73b0\u8fde\u63a5\u5f02\u5e38\u65f6&#xff0c;\u6309\u4e0b\u9762\u987a\u5e8f\u6392\u67e5&#xff1a;<\/p>\n<li>\u770b\u50f5\u5c38&#xff1a;ps -eo stat,pid,ppid,cmd | awk &#039;$1 ~ \/^Z\/&#039;&#xff0c;\u786e\u8ba4 PPID \u662f\u5426\u4e3a\u670d\u52a1\u8fdb\u7a0b\u3002<\/li>\n<li>\u770b fd&#xff1a;ls \/proc\/&lt;pid&gt;\/fd | wc -l&#xff0c;\u5224\u65ad\u7236\u8fdb\u7a0b\u662f\u5426\u5fd8\u8bb0 close\u3002<\/li>\n<li>\u770b backlog&#xff1a;ss -ltn \u89c2\u5bdf Send-Q&#xff08;backlog \u4e0a\u9650&#xff09;\u4e0e\u5f53\u524d\u8fde\u63a5\u5806\u79ef\u91cf\u3002<\/li>\n<li>\u770b\u4fe1\u53f7\u6ce8\u518c&#xff1a;grep SIGCHLD \/proc\/&lt;pid&gt;\/status \u65e0\u6cd5\u76f4\u63a5\u770b&#xff0c;\u9700\u56de\u5230\u4ee3\u7801\u786e\u8ba4 sigaction \u662f\u5426\u751f\u6548\u3002<\/li>\n<p><span class=\"token comment\"># \u4e00\u6761\u547d\u4ee4\u7ec4\u5408\u5b9a\u4f4d&#xff1a;\u50f5\u5c38\u6570 &#043; \u670d\u52a1\u8fdb\u7a0b fd \u603b\u6570 &#043; \u76d1\u542c\u961f\u5217\u72b6\u6001<\/span><br \/>\n<span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-eo<\/span> stat,pid,cmd <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> <span class=\"token parameter variable\">-c<\/span> <span class=\"token string\">&#039;^Z&#039;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token function\">ls<\/span> \/proc\/<span class=\"token variable\"><span class=\"token variable\">$(<\/span>pgrep <span class=\"token parameter variable\">-f<\/span> <span class=\"token string\">&#039;.\/srv&#039;<\/span><span class=\"token variable\">)<\/span><\/span>\/fd <span class=\"token operator\">|<\/span> <span class=\"token function\">wc<\/span> -l<span class=\"token punctuation\">;<\/span> ss <span class=\"token parameter variable\">-ltn<\/span><\/p>\n<p>\u6392\u9519\u987a\u5e8f\u6c38\u8fdc\u662f&#xff1a;\u5148\u786e\u8ba4\u56de\u6536\u94fe\u8def&#xff0c;\u518d\u6000\u7591\u5185\u6838\u53c2\u6570\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261119043308-6afe7c0438a01.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u7ed3\u8bed<\/h3>\n<p>\u8fd9\u5957\u65b9\u6848\u7684\u4ef7\u503c\u5728\u4e8e\u628a\u4e00\u4e2a\u300c\u80fd\u8dd1\u300d\u7684 TCP \u670d\u52a1\u5668\u63a8\u8fdb\u5230\u300c\u80fd\u957f\u671f\u8dd1\u300d&#xff1a;\u7236\u8fdb\u7a0b\u4e13\u804c accept \u4fdd\u8bc1\u8fde\u63a5\u4e0d\u6392\u961f&#xff0c;SIGCHLD &#043; waitpid \u5faa\u73af\u4fdd\u8bc1\u8fdb\u7a0b\u8868\u5e72\u51c0&#xff0c;\u53cc\u91cd fork \u518d\u628a\u5b64\u513f\u6536\u517b\u4ea4\u7ed9 init&#xff0c;\u6d88\u9664\u4e86\u4fe1\u53f7\u65f6\u5e8f\u7ade\u4e89\u7559\u4e0b\u7684\u6700\u540e\u6b7b\u89d2\u3002\u4e09\u6761\u94fe\u8def\u5f7c\u6b64\u72ec\u7acb&#xff0c;\u53ef\u4ee5\u6309\u9700\u9010\u7ea7\u542f\u7528&#xff0c;\u4e5f\u53ef\u4ee5\u76f4\u63a5\u6574\u4f53\u79fb\u690d\u5230\u73b0\u6709\u670d\u52a1\u4e2d\u3002<\/p>\n<p>\u7ebf\u4e0a\u6392\u9519\u65f6&#xff0c;\u53ea\u8981\u8bb0\u4f4f\u50f5\u5c38\u4e00\u5b9a\u6307\u5411\u7236\u8fdb\u7a0b\u7684\u56de\u6536\u7f3a\u5931&#xff0c;fd \u589e\u957f\u4e00\u5b9a\u6307\u5411 close \u9057\u6f0f&#xff0c;\u5c31\u80fd\u5feb\u901f\u7f29\u5c0f\u8303\u56f4\u3002<\/p>\n<p>\u5e76\u53d1\u4e0d\u662f\u8ba9\u4e00\u4e2a\u8fdb\u7a0b\u53d8\u5feb&#xff0c;\u800c\u662f\u8ba9\u6bcf\u4e2a\u8fde\u63a5\u90fd\u6709\u4eba\u8d1f\u8d23\u3001\u6bcf\u4e2a\u5b50\u8fdb\u7a0b\u90fd\u6709\u4eba\u6536\u5c3e\u3002<\/p>\n<p>      <span id=\"quality-guide-article-end\" aria-hidden=\"true\" style=\"display:block;height:1px;margin-bottom:-1px\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":124755,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14301,58,970,43,78],"topic":[],"class_list":["post-124758","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-14301","tag-linux","tag-tcp","tag-43","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b - \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\/124758.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/124758.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-19T04:33:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261119043305-6afe7c017bfb7.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=\"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\/124758.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/124758.html\",\"name\":\"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-19T04:33:10+00:00\",\"dateModified\":\"2026-11-19T04:33:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/124758.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/124758.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124758.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b\"}]},{\"@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":"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b - \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\/124758.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/124758.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-19T04:33:10+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261119043305-6afe7c017bfb7.png"}],"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\/124758.html","url":"https:\/\/www.wsisp.com\/helps\/124758.html","name":"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-19T04:33:10+00:00","dateModified":"2026-11-19T04:33:10+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/124758.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/124758.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/124758.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Linux\u7f51\u7edc\u3011TCP \u670d\u52a1\u5668\u5e76\u53d1\u5904\u7406\u591a\u5ba2\u6237\u7aef\uff1a\u4ece fork \u5206\u53d1\u5230\u53cc\u91cd fork \u5f7b\u5e95\u6d88\u706d\u50f5\u5c38\u8fdb\u7a0b"}]},{"@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\/124758","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=124758"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/124758\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/124755"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=124758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=124758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=124758"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=124758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}