{"id":96814,"date":"2026-08-28T12:40:58","date_gmt":"2026-08-28T04:40:58","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/96814.html"},"modified":"2026-08-28T12:40:58","modified_gmt":"2026-08-28T04:40:58","slug":"%e3%80%90linux%e3%80%91%e4%b8%a4%e4%b8%aa%e6%af%ab%e6%97%a0%e5%85%b3%e7%b3%bb%e7%9a%84%e8%bf%9b%e7%a8%8b%e6%80%8e%e4%b9%88%e9%80%9a%e4%bf%a1%ef%bc%9f%e5%91%bd%e5%90%8d%e7%ae%a1%e9%81%93-fifo-%e4%bb%8e","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/96814.html","title":{"rendered":"\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044055-6a911157b4013.png\" alt=\"\u5c01\u9762\" \/><\/p>\n<p>&#x1f525;\u4e2a\u4eba\u4e3b\u9875&#xff1a;<font color=\"whiblue\">\u7231\u548c\u51b0\u9614\u4e50<\/font> &#x1f4da;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b \u3001C&#043;&#043; &#x1f436;\u5b66\u4e60\u65b9\u5411&#xff1a;<font color=\"red\">C&#043;&#043;\u65b9\u5411\u5b66\u4e60\u7231\u597d\u8005<\/font> \u2b50\u4eba\u751f\u683c\u8a00&#xff1a;<font color=\"whiblue\">\u5f97\u77e5\u5766\u7136 &#xff0c;\u5931\u4e4b\u6de1\u7136 <\/font><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044056-6a9111581cddd.gif\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<hr \/>\n<p>&#x1f3e0;\u535a\u4e3b\u7b80\u4ecb <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044056-6a9111582f416.gif\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u524d\u8a00<\/li>\n<li>\u4e00\u3001\u533f\u540d\u7ba1\u9053\u7f3a\u7684\u4e0d\u662f\u201c\u7ba1\u9053\u201d&#xff0c;\u800c\u662f\u4e00\u4e2a\u53cc\u65b9\u90fd\u8ba4\u8bc6\u7684\u5165\u53e3<\/li>\n<li>\u4e8c\u3001\u5148\u7528\u547d\u4ee4\u628a FIFO \u7684\u884c\u4e3a\u8dd1\u51fa\u6765<\/li>\n<li>\n<ul>\n<li>2.1 &#096;mkfifo&#096;<\/li>\n<li>2.2 \u4e3a\u4ec0\u4e48 &#096;echo &gt; fifo&#096; \u4f1a\u5361\u4f4f<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001FIFO \u7684 &#096;open()&#096; \u89c4\u5219\u6bd4 &#096;read()&#096; \u66f4\u65e9\u5f00\u59cb\u540c\u6b65<\/li>\n<li>\u56db\u3001\u7cfb\u7edf\u8c03\u7528 &#096;mkfifo()&#096;<\/li>\n<li>\u4e94\u3001\u7528\u547d\u540d\u7ba1\u9053\u5199\u4e00\u4e2a\u6700\u5c0f Server \/ Client<\/li>\n<li>\n<ul>\n<li>5.1 Server<\/li>\n<li>5.2 Client<\/li>\n<\/ul>\n<\/li>\n<li>\u516d\u3001Client \u4e00\u9000\u51fa&#xff0c;Server \u4e3a\u4ec0\u4e48\u4f1a\u8bfb\u5230 &#096;0&#096;<\/li>\n<li>\u4e03\u3001\u533f\u540d\u7ba1\u9053\u548c\u547d\u540d\u7ba1\u9053\u5230\u5e95\u5dee\u5728\u54ea<\/li>\n<li>\u516b\u3001\u51e0\u4e2a\u5bb9\u6613\u7406\u89e3\u9519\u7684\u5730\u65b9<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>1. \u201c\u547d\u540d\u7ba1\u9053\u662f\u666e\u901a\u78c1\u76d8\u6587\u4ef6\u201d<\/li>\n<li>2. \u201c\u53ea\u8981\u6587\u4ef6\u8def\u5f84\u76f8\u540c&#xff0c;\u5c31\u4e00\u5b9a\u662f\u540c\u4e00\u4e2a\u6253\u5f00\u6587\u4ef6\u5bf9\u8c61\u201d<\/li>\n<li>3. Server \u5361\u4f4f\u4e00\u5b9a\u662f &#096;read()&#096;<\/li>\n<li>4. &#096;read()&#096; \u8bfb\u51fa\u6765\u5c31\u662f\u5b57\u7b26\u4e32<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3<\/li>\n<\/ul>\n<hr \/>\n<h2>\u524d\u8a00<\/h2>\n<p>\u524d\u9762\u5b66\u533f\u540d\u7ba1\u9053\u65f6\u6709\u4e00\u4e2a\u5f88\u660e\u663e\u7684\u9650\u5236&#xff1a;<\/p>\n<p>\u7236\u8fdb\u7a0b\u5148 pipe() \u2193 fork() \u2193 \u5b50\u8fdb\u7a0b\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684 fd \u2193 \u7236\u5b50\u8fdb\u7a0b\u770b\u5230\u540c\u4e00\u6761\u7ba1\u9053<\/p>\n<p>\u8fd9\u5957\u65b9\u6cd5\u5f88\u597d\u7528&#xff0c;\u4f46\u524d\u63d0\u662f\u4e24\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\u80fd\u901a\u8fc7 fork() \u5efa\u7acb\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u7ee7\u627f\u5173\u7cfb\u3002<\/p>\n<p>\u5982\u679c\u73b0\u5728\u6709\u4e24\u4e2a\u5b8c\u5168\u72ec\u7acb\u542f\u52a8\u7684\u7a0b\u5e8f&#xff1a;<\/p>\n<p>.\/server<br \/>\n.\/client<\/p>\n<p>\u5b83\u4eec\u6ca1\u6709\u7236\u5b50\u5173\u7cfb&#xff0c;\u4e5f\u6ca1\u6709\u8c01\u80fd\u628a\u81ea\u5df1\u5df2\u7ecf\u6253\u5f00\u7684\u533f\u540d\u7ba1\u9053 fd \u201c\u7ee7\u627f\u201d\u7ed9\u53e6\u4e00\u65b9\u3002<\/p>\n<p>\u90a3\u600e\u4e48\u8ba9\u5b83\u4eec\u627e\u5230\u540c\u4e00\u4efd\u5185\u6838\u901a\u4fe1\u8d44\u6e90&#xff1f;<\/p>\n<p>\u547d\u540d\u7ba1\u9053\u89e3\u51b3\u7684\u6b63\u662f\u201c\u4e24\u4e2a\u65e0\u4eb2\u7f18\u5173\u7cfb\u8fdb\u7a0b\u600e\u6837\u627e\u5230\u540c\u4e00\u4efd\u901a\u4fe1\u8d44\u6e90\u201d\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<hr \/>\n<h2>\u4e00\u3001\u533f\u540d\u7ba1\u9053\u7f3a\u7684\u4e0d\u662f\u201c\u7ba1\u9053\u201d&#xff0c;\u800c\u662f\u4e00\u4e2a\u53cc\u65b9\u90fd\u8ba4\u8bc6\u7684\u5165\u53e3<\/h2>\n<p>\u533f\u540d\u7ba1\u9053\u6ca1\u6709\u53ef\u4f9b\u65e0\u5173\u8fdb\u7a0b\u91cd\u65b0\u6253\u5f00\u7684\u8def\u5f84\u3002<\/p>\n<p><span class=\"token keyword\">int<\/span> pipefd<span class=\"token punctuation\">[<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">pipe<\/span><span class=\"token punctuation\">(<\/span>pipefd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>pipe() \u8fd4\u56de\u7684 pipefd[0]\u3001pipefd[1] \u53ea\u5bf9\u5f53\u524d\u8fdb\u7a0b\u4ee5\u53ca\u540e\u6765\u7ee7\u627f\u8fd9\u4e9b fd \u7684\u8fdb\u7a0b\u6709\u610f\u4e49\u3002<\/p>\n<p>\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u4e0d\u53ef\u80fd\u63d0\u524d\u77e5\u9053\u5bf9\u65b9\u8fdb\u7a0b\u91cc\u7684\u67d0\u4e2a fd \u662f\u591a\u5c11\u3002<\/p>\n<p>\u547d\u540d\u7ba1\u9053\u6362\u4e86\u4e00\u79cd\u601d\u8def&#xff1a;<\/p>\n<p><font color=\"#1E88E5\">\u4e0d\u518d\u9760 fd \u7ee7\u627f\u627e\u5230\u540c\u4e00\u6761\u7ba1\u9053&#xff0c;\u800c\u662f\u8ba9\u4e24\u4e2a\u8fdb\u7a0b\u7ea6\u5b9a\u540c\u4e00\u4e2a pathname\u3002<\/font><\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>\/tmp\/myfifo<\/p>\n<p>Server \u548c Client \u90fd\u53bb open(&#034;\/tmp\/myfifo&#034;, &#8230;)&#xff0c;\u5185\u6838\u5c31\u80fd\u628a\u5b83\u4eec\u8fde\u63a5\u5230\u540c\u4e00\u4e2a FIFO \u5bf9\u8c61\u4e0a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044056-6a9111585593d.png\" alt=\"\u547d\u540d\u7ba1\u9053\u8ba9\u65e0\u4eb2\u7f18\u5173\u7cfb\u8fdb\u7a0b\u901a\u8fc7\u540c\u4e00\u8def\u5f84\u627e\u5230\u540c\u4e00\u8d44\u6e90\" \/><\/p>\n<p>\u8fd9\u91cc\u6709\u4e2a\u5730\u65b9\u5f88\u5bb9\u6613\u7406\u89e3\u504f\u3002<\/p>\n<p>\u547d\u540d\u7ba1\u9053\u786e\u5b9e\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u62e5\u6709\u8def\u5f84\u3001\u76ee\u5f55\u9879\u548c\u6587\u4ef6\u7c7b\u578b&#xff0c;\u6267\u884c ls -l \u80fd\u770b\u5230\u5b83&#xff1b;\u4f46\u771f\u6b63\u4f20\u8f93\u7684\u6570\u636e\u5e76\u4e0d\u4f1a\u50cf\u666e\u901a\u6587\u4ef6\u4e00\u6837\u5199\u8fdb\u78c1\u76d8\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<p><font color=\"#F57C00\">\u8fd9\u91cc\u8bb0\u4f4f&#xff1a;<\/font><\/p>\n<p>\u8def\u5f84\u5b58\u5728\u4e8e\u6587\u4ef6\u7cfb\u7edf\u4e2d<br \/>\n        \u2193<br \/>\n\u7528\u4e8e\u8ba9\u4e0d\u540c\u8fdb\u7a0b\u627e\u5230\u540c\u4e00\u4e2a FIFO<br \/>\n        \u2193<br \/>\n\u901a\u4fe1\u6570\u636e\u4ecd\u7136\u5728\u5185\u6838\u7ba1\u9053\u673a\u5236\u4e2d\u6d41\u52a8<\/p>\n<p>\u6240\u4ee5\u201c\u6709\u6587\u4ef6\u540d\u201d\u4e0d\u7b49\u4e8e\u201c\u901a\u4fe1\u6570\u636e\u4f1a\u843d\u76d8\u201d\u3002<\/p>\n<hr \/>\n<h2>\u4e8c\u3001\u5148\u7528\u547d\u4ee4\u628a FIFO \u7684\u884c\u4e3a\u8dd1\u51fa\u6765<\/h2>\n<h3>2.1 mkfifo<\/h3>\n<p>\u521b\u5efa&#xff1a;<\/p>\n<p><span class=\"token function\">mkfifo<\/span> fifo<\/p>\n<p>\u67e5\u770b&#xff1a;<\/p>\n<p><span class=\"token function\">ls<\/span> <span class=\"token parameter variable\">-l<\/span> fifo<\/p>\n<p>\u547d\u540d\u7ba1\u9053\u7684\u6587\u4ef6\u7c7b\u578b\u901a\u5e38\u4f1a\u663e\u793a\u4e3a&#xff1a;<\/p>\n<p>p<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044057-6a91115902111.png\" alt=\"\u521b\u5efa FIFO \u540e\u67e5\u770b\u6587\u4ef6\u7c7b\u578b\" \/><\/p>\n<p>\u5220\u9664\u65f6\u76f4\u63a5&#xff1a;<\/p>\n<p><span class=\"token function\">rm<\/span> fifo<\/p>\n<p>\u6216\u8005&#xff1a;<\/p>\n<p>unlink fifo<\/p>\n<p>\u6ca1\u5fc5\u8981\u5199&#xff1a;<\/p>\n<p><span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-rf<\/span> fifo<\/p>\n<p>fifo \u4e0d\u662f\u76ee\u5f55&#xff0c;-r \u5728\u8fd9\u91cc\u6ca1\u6709\u610f\u4e49\u3002<\/p>\n<h3>2.2 \u4e3a\u4ec0\u4e48 echo &gt; fifo \u4f1a\u5361\u4f4f<\/h3>\n<p>\u5148\u6267\u884c&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;hello fifo&#034;<\/span> <span class=\"token operator\">&gt;<\/span> fifo<\/p>\n<p>\u5982\u679c\u6b64\u65f6\u6ca1\u6709\u4efb\u4f55\u8fdb\u7a0b\u4ee5\u8bfb\u65b9\u5f0f\u6253\u5f00 FIFO&#xff0c;Shell \u4f1a\u505c\u5728\u90a3\u91cc\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044057-6a911159151dc.png\" alt=\"\u5199\u7aef\u7b49\u5f85\u8bfb\u7aef\u6253\u5f00 FIFO\" \/><\/p>\n<p>\u53e6\u5f00\u4e00\u4e2a\u7ec8\u7aef&#xff1a;<\/p>\n<p><span class=\"token function\">cat<\/span> fifo<\/p>\n<p>\u6b64\u65f6\u4e24\u8fb9\u90fd\u4f1a\u7ee7\u7eed\u8fd0\u884c&#xff0c;cat \u80fd\u8bfb\u5230&#xff1a;<\/p>\n<p>hello fifo<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044057-6a91115928799.png\" alt=\"\u53e6\u4e00\u4e2a\u7ec8\u7aef\u6253\u5f00\u8bfb\u7aef\u540e\u5b8c\u6210\u901a\u4fe1\" \/><\/p>\n<p>\u8fd9\u4e00\u6b65\u6700\u503c\u5f97\u89c2\u5bdf\u7684\u662f&#xff1a;<\/p>\n<p>\u5199\u7aef open(O_WRONLY)<br \/>\n        \u2502<br \/>\n        \u2502 \u6ca1\u6709\u8bfb\u7aef\u65f6\u7b49\u5f85<br \/>\n        \u25bc<br \/>\n\u8bfb\u7aef open(O_RDONLY)<br \/>\n        \u2502<br \/>\n        \u25bc<br \/>\n\u53cc\u65b9\u5efa\u7acb\u901a\u4fe1\u5173\u7cfb<\/p>\n<hr \/>\n<h2>\u4e09\u3001FIFO \u7684 open() \u89c4\u5219\u6bd4 read() \u66f4\u65e9\u5f00\u59cb\u540c\u6b65<\/h2>\n<p>\u9ed8\u8ba4\u963b\u585e\u6a21\u5f0f\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u6253\u5f00\u65b9\u5f0f\u53e6\u4e00\u7aef\u4e0d\u5b58\u5728\u65f6<\/tr>\n<tbody>\n<tr>\n<td>open(&#8230;, O_RDONLY)<\/td>\n<td>\u7b49\u5f85\u67d0\u4e2a\u5199\u7aef\u6253\u5f00<\/td>\n<\/tr>\n<tr>\n<td>open(&#8230;, O_WRONLY)<\/td>\n<td>\u7b49\u5f85\u67d0\u4e2a\u8bfb\u7aef\u6253\u5f00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u963b\u585e\u751a\u81f3\u53ef\u80fd\u53d1\u751f\u5728 open()&#xff0c;\u4ee3\u7801\u8fd8\u6ca1\u6709\u8d70\u5230 read() \u6216 write()\u3002<\/p>\n<p>\u5982\u679c\u4f7f\u7528 O_NONBLOCK&#xff0c;\u89c4\u5219\u4f1a\u53d8\u5316&#xff1a;<\/p>\n<p>O_RDONLY | O_NONBLOCK<\/p>\n<p>\u53ef\u4ee5\u7acb\u5373\u6253\u5f00\u3002<\/p>\n<p>\u800c&#xff1a;<\/p>\n<p>O_WRONLY | O_NONBLOCK<\/p>\n<p>\u5982\u679c\u4e00\u4e2a\u8bfb\u7aef\u90fd\u4e0d\u5b58\u5728&#xff0c;\u4f1a\u5931\u8d25\u5e76\u5f97\u5230 ENXIO\u3002<\/p>\n<p><font color=\"#2E7D32\">\u6392\u67e5 FIFO \u201c\u7a0b\u5e8f\u4e00\u542f\u52a8\u5c31\u5361\u4f4f\u201d\u65f6&#xff0c;\u5148\u770b open() \u6709\u6ca1\u6709\u8fd4\u56de\u3002<\/font><\/p>\n<p>\u5f88\u591a\u65f6\u5019\u4e0d\u662f read() \u5361\u4f4f&#xff0c;\u800c\u662f&#xff1a;<\/p>\n<p><span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span>FIFO_FILE<span class=\"token punctuation\">,<\/span> O_RDONLY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6839\u672c\u8fd8\u6ca1\u6709\u8fd4\u56de\u3002<\/p>\n<hr \/>\n<h2>\u56db\u3001\u7cfb\u7edf\u8c03\u7528 mkfifo()<\/h2>\n<p>\u7a0b\u5e8f\u4e2d\u521b\u5efa FIFO&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/types.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/stat.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">mkfifo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>pathname<span class=\"token punctuation\">,<\/span> mode_t mode<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6210\u529f\u8fd4\u56de&#xff1a;<\/p>\n<p>0<\/p>\n<p>\u5931\u8d25\u8fd4\u56de&#xff1a;<\/p>\n<p>-1<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;cerrno&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;cstdio&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/stat.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> FIFO_FILE <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;.\/myfifo&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">umask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">mkfifo<\/span><span class=\"token punctuation\">(<\/span>FIFO_FILE<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0666<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>errno <span class=\"token operator\">!&#061;<\/span> EEXIST<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;mkfifo&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>Server \u53ef\u80fd\u88ab\u91cd\u590d\u542f\u52a8&#xff0c;\u6240\u4ee5\u9047\u5230 EEXIST \u65f6\u4e0d\u8981\u5148\u8ba4\u5b9a\u7a0b\u5e8f\u51fa\u9519\u3002<\/p>\n<p>\u5982\u679c\u8def\u5f84\u5df2\u7ecf\u5b58\u5728&#xff0c;\u8fd8\u5e94\u8be5\u786e\u8ba4\u5b83\u662f\u4e0d\u662f\u6211\u4eec\u671f\u671b\u7684 FIFO&#xff0c;\u800c\u4e0d\u662f\u540c\u540d\u666e\u901a\u6587\u4ef6\u3002<\/p>\n<hr \/>\n<h2>\u4e94\u3001\u7528\u547d\u540d\u7ba1\u9053\u5199\u4e00\u4e2a\u6700\u5c0f Server \/ Client<\/h2>\n<p>Server&#xff1a;\u8bfb\u7aef<br \/>\nClient&#xff1a;\u5199\u7aef<\/p>\n<h3>5.1 Server<\/h3>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;cerrno&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;cstdio&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;cstdlib&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;fcntl.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/stat.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> FIFO_FILE <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;.\/myfifo&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">umask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">mkfifo<\/span><span class=\"token punctuation\">(<\/span>FIFO_FILE<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0666<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span> <span class=\"token operator\">&amp;&amp;<\/span> errno <span class=\"token operator\">!&#061;<\/span> EEXIST<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;mkfifo&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;\u7b49\u5f85 client \u6253\u5f00 FIFO&#8230;&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">int<\/span> fd <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span>FIFO_FILE<span class=\"token punctuation\">,<\/span> O_RDONLY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>fd <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;open&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">unlink<\/span><span class=\"token punctuation\">(<\/span>FIFO_FILE<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">char<\/span> buffer<span class=\"token punctuation\">[<\/span><span class=\"token number\">1024<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token boolean\">true<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        ssize_t n <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">,<\/span> buffer<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>buffer<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 punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>n <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">{<\/span><br \/>\n            buffer<span class=\"token punctuation\">[<\/span>n<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token char\">&#039;\\\\0&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;client say# &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> buffer <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>n <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">{<\/span><br \/>\n            std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;\u6240\u6709\u5199\u7aef\u5df2\u7ecf\u5173\u95ed&#xff0c;server \u7ed3\u675f\u8bfb\u53d6&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">else<\/span><br \/>\n        <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;read&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">unlink<\/span><span class=\"token punctuation\">(<\/span>FIFO_FILE<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u91cc\u987a\u624b\u4fee\u6b63\u539f\u7a3f\u4e2d\u7684\u4e00\u4e2a\u7ec6\u8282\u3002\u539f\u6765\u5199\u7684\u662f&#xff1a;<\/p>\n<p>buffer<span class=\"token punctuation\">[<\/span>n <span class=\"token operator\">&#8211;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6539\u6210&#xff1a;<\/p>\n<p>buffer<span class=\"token punctuation\">[<\/span>n<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token char\">&#039;\\\\0&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>read() \u8fd4\u56de\u7684 n \u5c31\u662f\u672c\u6b21\u5b9e\u9645\u8bfb\u5230\u7684\u6709\u6548\u5b57\u8282\u6570\u3002<\/p>\n<p>\u5982\u679c\u4f60\u7684\u76ee\u7684\u53ea\u662f\u7ed9 C \u5b57\u7b26\u4e32\u8865\u7ed3\u675f\u7b26&#xff0c;\u5e94\u8be5\u653e\u5728\u6709\u6548\u6570\u636e\u540e\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/p>\n<p>\u53ea\u6709\u4f60\u660e\u786e\u77e5\u9053\u6700\u540e\u4e00\u4e2a\u5b57\u8282\u4e00\u5b9a\u662f\u6362\u884c\u7b26&#xff0c;\u5e76\u4e14\u60f3\u628a\u6362\u884c\u5220\u6389\u65f6&#xff0c;\u624d\u8003\u8651\u6539 buffer[n &#8211; 1]\u3002<\/p>\n<h3>5.2 Client<\/h3>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;cstdio&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;fcntl.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> FIFO_FILE <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;.\/myfifo&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> fd <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span>FIFO_FILE<span class=\"token punctuation\">,<\/span> O_WRONLY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>fd <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;open&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">int<\/span> count <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    pid_t pid <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">getpid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token boolean\">true<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;Please Enter# &#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        std<span class=\"token double-colon punctuation\">::<\/span>string message<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>std<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">getline<\/span><span class=\"token punctuation\">(<\/span>std<span class=\"token double-colon punctuation\">::<\/span>cin<span class=\"token punctuation\">,<\/span> message<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        message <span class=\"token operator\">&#043;&#061;<\/span> <span class=\"token string\">&#034;, message number &#034;<\/span> <span class=\"token operator\">&#043;<\/span><br \/>\n                   std<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">to_string<\/span><span class=\"token punctuation\">(<\/span>count<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span><br \/>\n                   <span class=\"token string\">&#034; [pid&#061;&#034;<\/span> <span class=\"token operator\">&#043;<\/span><br \/>\n                   std<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">to_string<\/span><span class=\"token punctuation\">(<\/span>pid<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span><br \/>\n                   <span class=\"token string\">&#034;]&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        ssize_t n <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">write<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">,<\/span> message<span class=\"token punctuation\">.<\/span><span class=\"token function\">c_str<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> message<span class=\"token punctuation\">.<\/span><span class=\"token function\">size<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>n <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;write&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd0\u884c&#xff1a;<\/p>\n<p>.\/server<\/p>\n<p>\u518d\u6253\u5f00\u53e6\u4e00\u4e2a\u7ec8\u7aef&#xff1a;<\/p>\n<p>.\/client<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044057-6a91115941aa5.png\" alt=\"\u547d\u540d\u7ba1\u9053 Server \u4e0e Client \u901a\u4fe1\u7ed3\u679c\" \/><\/p>\n<hr \/>\n<h2>\u516d\u3001Client \u4e00\u9000\u51fa&#xff0c;Server \u4e3a\u4ec0\u4e48\u4f1a\u8bfb\u5230 0<\/h2>\n<p>\u5047\u8bbe Client \u6b63\u5e38\u9000\u51fa&#xff1a;<\/p>\n<p><span class=\"token function\">close<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5982\u679c\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u4e0d\u5b58\u5728\u4efb\u4f55\u5199\u7aef&#xff0c;\u90a3\u4e48 Server \u7ee7\u7eed&#xff1a;<\/p>\n<p><span class=\"token function\">read<\/span><span class=\"token punctuation\">(<\/span>fd<span class=\"token punctuation\">,<\/span> buffer<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>buffer<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5f53 FIFO \u4e2d\u5269\u4f59\u6570\u636e\u5df2\u7ecf\u5168\u90e8\u8bfb\u5b8c\u540e&#xff0c;read() \u8fd4\u56de&#xff1a;<\/p>\n<p>0<\/p>\n<p>\u8fd9\u5c31\u662f EOF\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044057-6a911159648c2.png\" alt=\"\u5199\u7aef\u9000\u51fa\u540e\u8bfb\u7aef\u8bfb\u53d6\u5230 EOF\" \/><\/p>\n<p><font color=\"#1E88E5\">\u8fd9\u91cc\u548c\u533f\u540d\u7ba1\u9053\u662f\u4e00\u5957\u89c4\u5219&#xff1a;<\/font><\/p>\n<p>\u6709\u6ca1\u6709\u8def\u5f84&#xff0c;\u53ea\u51b3\u5b9a\u53cc\u65b9\u600e\u4e48\u201c\u627e\u5230\u201d\u7ba1\u9053<br \/>\n\u8bfb\u5199\u7aef\u3001EOF\u3001SIGPIPE\u3001\u5b57\u8282\u6d41\u89c4\u5219&#xff0c;\u4ecd\u7136\u5c5e\u4e8e\u7ba1\u9053\u8bed\u4e49<\/p>\n<hr \/>\n<h2>\u4e03\u3001\u533f\u540d\u7ba1\u9053\u548c\u547d\u540d\u7ba1\u9053\u5230\u5e95\u5dee\u5728\u54ea<\/h2>\n<p>\u533f\u540d\u7ba1\u9053\u548c\u547d\u540d\u7ba1\u9053\u7684\u533a\u522b\u4e0d\u7528\u80cc\u5f88\u591a\u6761&#xff0c;\u6293\u4f4f\u201c\u53cc\u65b9\u600e\u6837\u627e\u5230\u540c\u4e00\u6761\u7ba1\u9053\u201d\u6700\u91cd\u8981\u3002<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u533f\u540d\u7ba1\u9053\u547d\u540d\u7ba1\u9053 FIFO<\/tr>\n<tbody>\n<tr>\n<td>\u521b\u5efa\u65b9\u5f0f<\/td>\n<td>pipe()<\/td>\n<td>mkfifo()<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u6709\u8def\u5f84<\/td>\n<td>\u6ca1\u6709<\/td>\n<td>\u6709<\/td>\n<\/tr>\n<tr>\n<td>\u5e38\u89c1\u4f7f\u7528\u5173\u7cfb<\/td>\n<td>\u7236\u5b50\u7b49\u6709\u4eb2\u7f18\u5173\u7cfb\u8fdb\u7a0b<\/td>\n<td>\u65e0\u4eb2\u7f18\u5173\u7cfb\u8fdb\u7a0b\u4e5f\u53ef\u4ee5<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u662f\u5426\u843d\u76d8<\/td>\n<td>\u5426<\/td>\n<td>\u5426<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u5f62\u5f0f<\/td>\n<td>\u5b57\u8282\u6d41<\/td>\n<td>\u5b57\u8282\u6d41<\/td>\n<\/tr>\n<tr>\n<td>\u963b\u585e\u3001EOF\u3001SIGPIPE<\/td>\n<td>\u6709<\/td>\n<td>\u6709<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><font color=\"#2E7D32\">\u6838\u5fc3\u533a\u522b&#xff1a;<\/font><\/p>\n<p>\u533f\u540d\u7ba1\u9053\u901a\u5e38\u9760 fork() \u7ee7\u627f fd&#xff1b;<\/p>\n<p>\u547d\u540d\u7ba1\u9053\u9760\u53cc\u65b9\u6253\u5f00\u540c\u4e00\u4e2a pathname \u5efa\u7acb\u8054\u7cfb\u3002<\/p>\n<hr \/>\n<h2>\u516b\u3001\u51e0\u4e2a\u5bb9\u6613\u7406\u89e3\u9519\u7684\u5730\u65b9<\/h2>\n<h4>1. \u201c\u547d\u540d\u7ba1\u9053\u662f\u666e\u901a\u78c1\u76d8\u6587\u4ef6\u201d<\/h4>\n<p>\u4e0d\u5bf9\u3002<\/p>\n<p>\u5b83\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u6709\u540d\u5b57\u548c\u7c7b\u578b&#xff0c;\u4f46 FIFO \u4e2d\u4f20\u9012\u7684\u5b57\u8282\u5e76\u4e0d\u662f\u666e\u901a\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<h4>2. \u201c\u53ea\u8981\u6587\u4ef6\u8def\u5f84\u76f8\u540c&#xff0c;\u5c31\u4e00\u5b9a\u662f\u540c\u4e00\u4e2a\u6253\u5f00\u6587\u4ef6\u5bf9\u8c61\u201d<\/h4>\n<p>\u4e5f\u4e0d\u80fd\u8fd9\u4e48\u8bf4\u3002<\/p>\n<p>\u591a\u4e2a open() \u4f1a\u5f62\u6210\u5404\u81ea\u7684\u6253\u5f00\u5b9e\u4f8b\u548c fd&#xff0c;\u5e95\u5c42\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61\u5b58\u5728\u5171\u4eab\u5173\u7cfb&#xff0c;\u4f46\u4e0d\u8981\u7b80\u5355\u5199\u6210\u201c\u4e24\u4e2a\u8fdb\u7a0b\u7684 struct file \u5b8c\u5168\u662f\u540c\u4e00\u4e2a\u201d\u3002<\/p>\n<h4>3. Server \u5361\u4f4f\u4e00\u5b9a\u662f read()<\/h4>\n<p>\u4e0d\u4e00\u5b9a\u3002<\/p>\n<p>\u8bfb\u7aef&#xff1a;<\/p>\n<p><span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span>path<span class=\"token punctuation\">,<\/span> O_RDONLY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u6ca1\u6709\u5199\u7aef\u65f6\u5c31\u53ef\u80fd\u5df2\u7ecf\u963b\u585e\u3002<\/p>\n<h4>4. read() \u8bfb\u51fa\u6765\u5c31\u662f\u5b57\u7b26\u4e32<\/h4>\n<p>\u4e0d\u662f\u3002<\/p>\n<p>read() \u53ea\u8ba4\u8bc6\u5b57\u8282&#xff0c;\u4e0d\u8ba4\u8bc6 C \u5b57\u7b26\u4e32\u7ed3\u5c3e\u7684 &#039;\\\\0&#039;\u3002<\/p>\n<p>\u6240\u4ee5&#xff1a;<\/p>\n<p>buffer<span class=\"token punctuation\">[<\/span>n<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token char\">&#039;\\\\0&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u662f\u7528\u6237\u4ee3\u7801\u81ea\u5df1\u8865\u7684\u3002<\/p>\n<hr \/>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u547d\u540d\u7ba1\u9053\u6ca1\u6709\u6539\u53d8\u7ba1\u9053\u4f20\u8f93\u6570\u636e\u7684\u672c\u8d28&#xff0c;\u5b83\u53ea\u662f\u89e3\u51b3\u4e86\u533f\u540d\u7ba1\u9053\u6700\u9ebb\u70e6\u7684\u90a3\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<p>\u4e24\u4e2a\u6ca1\u6709\u4eb2\u7f18\u5173\u7cfb\u7684\u8fdb\u7a0b<br \/>\n\u5230\u5e95\u600e\u6837\u627e\u5230\u540c\u4e00\u6761\u7ba1\u9053&#xff1f;<\/p>\n<p>\u7b54\u6848\u5c31\u662f pathname\u3002<\/p>\n<p>Server \u548c Client \u7ea6\u5b9a&#xff1a;<\/p>\n<p>.\/myfifo<\/p>\n<p>\u5404\u81ea\u8c03\u7528 open()&#xff0c;\u5c31\u80fd\u8fde\u63a5\u5230\u540c\u4e00\u6761 FIFO\u3002<\/p>\n<p>\u6700\u540e\u628a\u8fd9\u7bc7\u771f\u6b63\u8981\u8bb0\u4f4f\u7684\u5185\u5bb9\u6536\u4e00\u4e0b&#xff1a;<\/p>\n<ul>\n<li>mkfifo() \u521b\u5efa\u7684\u662f FIFO \u7279\u6b8a\u6587\u4ef6&#xff1b;<\/li>\n<li>FIFO \u6570\u636e\u4e0d\u4f1a\u4f5c\u4e3a\u666e\u901a\u6587\u4ef6\u5185\u5bb9\u5237\u5230\u78c1\u76d8&#xff1b;<\/li>\n<li>\u963b\u585e\u53ef\u80fd\u4ece open() \u5c31\u5f00\u59cb&#xff1b;<\/li>\n<li>read() \u8fd4\u56de 0 \u8868\u793a\u6240\u6709\u5199\u7aef\u5173\u95ed\u5e76\u4e14\u5269\u4f59\u6570\u636e\u5df2\u7ecf\u8bfb\u5b8c&#xff1b;<\/li>\n<li>\u547d\u540d\u7ba1\u9053\u548c\u533f\u540d\u7ba1\u9053\u7684\u4e3b\u8981\u533a\u522b&#xff0c;\u662f\u201c\u53cc\u65b9\u600e\u6837\u627e\u5230\u540c\u4e00\u8d44\u6e90\u201d\u3002<\/li>\n<\/ul>\n<p>\u4e0b\u4e00\u7bc7\u7ee7\u7eed\u6cbf\u7740\u201c\u8ba9\u4e0d\u540c\u8fdb\u7a0b\u770b\u5230\u540c\u4e00\u4efd\u8d44\u6e90\u201d\u5f80\u4e0b\u8d70&#xff0c;\u4e0d\u8fc7\u4e0d\u518d\u501f\u52a9\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u800c\u662f\u76f4\u63a5\u628a\u540c\u4e00\u6279\u7269\u7406\u9875\u6620\u5c04\u8fdb\u591a\u4e2a\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u2014\u2014System V \u5171\u4eab\u5185\u5b58\u3002<\/p>\n<p>\u8d44\u6e90\u5206\u4eab&#xff1a; \u3010Linux\u3011\u4ece\u533f\u540d\u7ba1\u9053\u5230\u8fdb\u7a0b\u6c60&#xff1a;\u4efb\u52a1\u6d3e\u53d1\u3001fd \u7ee7\u627f Bug \u4e0e\u5b8c\u6574\u5b9e\u73b0 \u3010Linux\u3011\u8fdb\u7a0b\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u901a\u4fe1&#xff1f;\u533f\u540d\u7ba1\u9053\u539f\u7406\u3001fd \u7ee7\u627f\u4e0e\u8bfb\u5199\u89c4\u5219 \u3010Linux\u3011\u6ca1\u6709\u516c\u7f51 IP \u4e5f\u80fd SSH \u56de\u5185\u7f51&#xff1a;\u53cd\u5411 SSH\u3001ProxyJump \u4e0e systemd \u4fdd\u6d3b\u5b9e\u6218<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f525;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u7231\u548c\u51b0\u9614\u4e50 &#x1f4da;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b \u3001C &#x1f436;\u5b66\u4e60\u65b9\u5411&#xff1a;C\u65b9\u5411\u5b66\u4e60\u7231\u597d\u8005 \u2b50\u4eba\u751f\u683c\u8a00&#xff1a;\u5f97\u77e5\u5766\u7136 &#xff0c;\u5931\u4e4b\u6de1\u7136  &#x1f3e0;\u535a\u4e3b\u7b80\u4ecb  \u6587\u7ae0\u76ee\u5f55\u524d\u8a00\u4e00\u3001\u533f\u540d\u7ba1\u9053\u7f3a\u7684\u4e0d\u662f\u201c\u7ba1\u9053\u201d&#xff0c;\u800c\u662f\u4e00\u4e2a\u53cc\u65b9\u90fd\u8ba4\u8bc6\u7684\u5165\u53e3\u4e8c\u3001\u5148\u7528\u547d\u4ee4\u628a FIFO \u7684\u884c\u4e3a\u8dd1\u51fa\u67652.1 mkfifo2.2 \u4e3a\u4ec0\u4e48 echo &gt; fifo \u4f1a\u5361\u4f4f\u4e09\u3001FIFO \u7684 <\/p>\n","protected":false},"author":2,"featured_media":96805,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,84,55,58,1802,100],"topic":[],"class_list":["post-96814","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-codingplan","tag-android","tag-c","tag-linux","tag-vim","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218 - \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\/96814.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f525;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u7231\u548c\u51b0\u9614\u4e50 &#x1f4da;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b \u3001C &#x1f436;\u5b66\u4e60\u65b9\u5411&#xff1a;C\u65b9\u5411\u5b66\u4e60\u7231\u597d\u8005 \u2b50\u4eba\u751f\u683c\u8a00&#xff1a;\u5f97\u77e5\u5766\u7136 &#xff0c;\u5931\u4e4b\u6de1\u7136 &#x1f3e0;\u535a\u4e3b\u7b80\u4ecb \u6587\u7ae0\u76ee\u5f55\u524d\u8a00\u4e00\u3001\u533f\u540d\u7ba1\u9053\u7f3a\u7684\u4e0d\u662f\u201c\u7ba1\u9053\u201d&#xff0c;\u800c\u662f\u4e00\u4e2a\u53cc\u65b9\u90fd\u8ba4\u8bc6\u7684\u5165\u53e3\u4e8c\u3001\u5148\u7528\u547d\u4ee4\u628a FIFO \u7684\u884c\u4e3a\u8dd1\u51fa\u67652.1 mkfifo2.2 \u4e3a\u4ec0\u4e48 echo &gt; fifo \u4f1a\u5361\u4f4f\u4e09\u3001FIFO \u7684\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/96814.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-28T04:40:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044055-6a911157b4013.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\/96814.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/96814.html\",\"name\":\"\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-28T04:40:58+00:00\",\"dateModified\":\"2026-08-28T04:40:58+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/96814.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/96814.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/96814.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218\"}]},{\"@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\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218 - \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\/96814.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f525;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u7231\u548c\u51b0\u9614\u4e50 &#x1f4da;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b \u3001C &#x1f436;\u5b66\u4e60\u65b9\u5411&#xff1a;C\u65b9\u5411\u5b66\u4e60\u7231\u597d\u8005 \u2b50\u4eba\u751f\u683c\u8a00&#xff1a;\u5f97\u77e5\u5766\u7136 &#xff0c;\u5931\u4e4b\u6de1\u7136 &#x1f3e0;\u535a\u4e3b\u7b80\u4ecb \u6587\u7ae0\u76ee\u5f55\u524d\u8a00\u4e00\u3001\u533f\u540d\u7ba1\u9053\u7f3a\u7684\u4e0d\u662f\u201c\u7ba1\u9053\u201d&#xff0c;\u800c\u662f\u4e00\u4e2a\u53cc\u65b9\u90fd\u8ba4\u8bc6\u7684\u5165\u53e3\u4e8c\u3001\u5148\u7528\u547d\u4ee4\u628a FIFO \u7684\u884c\u4e3a\u8dd1\u51fa\u67652.1 mkfifo2.2 \u4e3a\u4ec0\u4e48 echo &gt; fifo \u4f1a\u5361\u4f4f\u4e09\u3001FIFO \u7684","og_url":"https:\/\/www.wsisp.com\/helps\/96814.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-28T04:40:58+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260828044055-6a911157b4013.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\/96814.html","url":"https:\/\/www.wsisp.com\/helps\/96814.html","name":"\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-28T04:40:58+00:00","dateModified":"2026-08-28T04:40:58+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/96814.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/96814.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/96814.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Linux\u3011\u4e24\u4e2a\u6beb\u65e0\u5173\u7cfb\u7684\u8fdb\u7a0b\u600e\u4e48\u901a\u4fe1\uff1f\u547d\u540d\u7ba1\u9053 FIFO \u4ece\u539f\u7406\u5230 Server\/Client \u5b9e\u6218"}]},{"@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\/96814","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=96814"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/96814\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/96805"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=96814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=96814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=96814"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=96814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}