{"id":75090,"date":"2026-02-11T11:57:50","date_gmt":"2026-02-11T03:57:50","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/75090.html"},"modified":"2026-02-11T11:57:50","modified_gmt":"2026-02-11T03:57:50","slug":"%e3%80%90linux%e7%b3%bb%e7%bb%9f%e7%bc%96%e7%a8%8b%e3%80%91%ef%bc%88%e4%b8%89%e5%8d%81%e4%ba%8c%ef%bc%89%e5%91%bd%e5%90%8d%e7%ae%a1%e9%81%93-fifo-%e7%b2%be%e8%ae%b2%ef%bc%9a%e7%aa%81%e7%a0%b4%e4%ba%b2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/75090.html","title":{"rendered":"\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1"},"content":{"rendered":"<h2 id=\"%E2%80%8B%E7%BC%96%E8%BE%91\" style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260211035748-698bfe3c281fb.gif\" \/><\/h2>\n<hr \/>\n<h2 id=\"main-toc\">\u76ee\u5f55<\/h2>\n<p id=\"%E5%89%8D%E8%A8%80-toc\" style=\"margin-left:0px\">\u524d\u8a00<\/p>\n<p id=\"%E4%B8%80%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E8%AF%9E%E7%94%9F%EF%BC%9A%E8%A7%A3%E5%86%B3%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E7%97%9B%E7%82%B9-toc\" style=\"margin-left:0px\">\u4e00\u3001\u547d\u540d\u7ba1\u9053\u7684\u8bde\u751f&#xff1a;\u89e3\u51b3\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u75db\u70b9<\/p>\n<p id=\"1.1%20%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E8%87%B4%E5%91%BD%E7%9F%AD%E6%9D%BF-toc\" style=\"margin-left:40px\">1.1 \u533f\u540d\u7ba1\u9053\u7684\u81f4\u547d\u77ed\u677f<\/p>\n<p id=\"1.2%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E8%AE%BE%E8%AE%A1%E6%80%9D%E8%B7%AF-toc\" style=\"margin-left:40px\">1.2 \u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8bbe\u8ba1\u601d\u8def<\/p>\n<p id=\"1.3%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E4%B8%8E%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E5%85%B3%E8%81%94-toc\" style=\"margin-left:40px\">1.3 \u547d\u540d\u7ba1\u9053\u4e0e\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u5173\u8054<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E8%AE%A4%E7%9F%A5%EF%BC%9A%E4%BB%80%E4%B9%88%E6%98%AF%20FIFO%20%E6%96%87%E4%BB%B6%EF%BC%9F-toc\" style=\"margin-left:0px\">\u4e8c\u3001\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8ba4\u77e5&#xff1a;\u4ec0\u4e48\u662f FIFO \u6587\u4ef6&#xff1f;<\/p>\n<p id=\"2.1%20FIFO%20%E6%96%87%E4%BB%B6%E7%9A%84%E6%9C%AC%E8%B4%A8-toc\" style=\"margin-left:40px\">2.1 FIFO \u6587\u4ef6\u7684\u672c\u8d28<\/p>\n<p id=\"2.2%20FIFO%20%E6%96%87%E4%BB%B6%E7%9A%84%E6%A0%87%E8%AF%86-toc\" style=\"margin-left:40px\">2.2 FIFO \u6587\u4ef6\u7684\u6807\u8bc6<\/p>\n<p id=\"2.3%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E9%80%9A%E4%BF%A1%E6%A8%A1%E5%9E%8B-toc\" style=\"margin-left:40px\">2.3 \u547d\u540d\u7ba1\u9053\u7684\u901a\u4fe1\u6a21\u578b<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%88%9B%E5%BB%BA%EF%BC%9Amkfifo%20()%20%E5%87%BD%E6%95%B0%E4%B8%8E%E5%91%BD%E4%BB%A4%E8%A1%8C-toc\" style=\"margin-left:0px\">\u4e09\u3001\u547d\u540d\u7ba1\u9053\u7684\u521b\u5efa&#xff1a;mkfifo () \u51fd\u6570\u4e0e\u547d\u4ee4\u884c<\/p>\n<p id=\"3.1%20%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%88%9B%E5%BB%BA%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93-toc\" style=\"margin-left:40px\">3.1 \u547d\u4ee4\u884c\u521b\u5efa\u547d\u540d\u7ba1\u9053<\/p>\n<p id=\"3.2%20%E7%A8%8B%E5%BA%8F%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%EF%BC%9Amkfifo%20()%20%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:40px\">3.2 \u7a0b\u5e8f\u4e2d\u521b\u5efa\u547d\u540d\u7ba1\u9053&#xff1a;mkfifo () \u51fd\u6570<\/p>\n<p id=\"3.2.1%20mkfifo%20()%20%E5%87%BD%E6%95%B0%E6%8E%A5%E5%8F%A3-toc\" style=\"margin-left:80px\">3.2.1 mkfifo () \u51fd\u6570\u63a5\u53e3<\/p>\n<p id=\"3.2.2%20%E6%A0%B8%E5%BF%83%E6%B3%A8%E6%84%8F%E7%82%B9-toc\" style=\"margin-left:80px\">3.2.2 \u6838\u5fc3\u6ce8\u610f\u70b9<\/p>\n<p id=\"3.2.3%20%E7%AE%80%E5%8D%95%E5%88%9B%E5%BB%BA%E7%A4%BA%E4%BE%8B-toc\" style=\"margin-left:80px\">3.2.3 \u7b80\u5355\u521b\u5efa\u793a\u4f8b<\/p>\n<p id=\"%E5%9B%9B%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%89%93%E5%BC%80%E8%A7%84%E5%88%99%EF%BC%9A%E6%9C%80%E5%85%B3%E9%94%AE%E7%9A%84%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E7%82%B9-toc\" style=\"margin-left:0px\">\u56db\u3001\u547d\u540d\u7ba1\u9053\u7684\u6253\u5f00\u89c4\u5219&#xff1a;\u6700\u5173\u952e\u7684\u6838\u5fc3\u77e5\u8bc6\u70b9<\/p>\n<p id=\"4.1%20open%20()%20%E5%87%BD%E6%95%B0%E7%9A%84%E6%A0%B8%E5%BF%83%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:40px\">4.1 open () \u51fd\u6570\u7684\u6838\u5fc3\u53c2\u6570<\/p>\n<p id=\"4.2%20%E4%BB%A5%E8%AF%BB%E6%96%B9%E5%BC%8F%E6%89%93%E5%BC%80%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%EF%BC%88O_RDONLY%EF%BC%89-toc\" style=\"margin-left:40px\">4.2 \u4ee5\u8bfb\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff08;O_RDONLY&#xff09;<\/p>\n<p id=\"4.2.1%20%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88%E9%BB%98%E8%AE%A4%EF%BC%8C%E4%BB%85%20O_RDONLY%EF%BC%89-toc\" style=\"margin-left:80px\">4.2.1 \u963b\u585e\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff0c;\u4ec5 O_RDONLY&#xff09;<\/p>\n<p id=\"4.2.2%20%E9%9D%9E%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88O_RDONLY%20%7C%20O_NONBLOCK%EF%BC%89-toc\" style=\"margin-left:80px\">4.2.2 \u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_RDONLY | O_NONBLOCK&#xff09;<\/p>\n<p id=\"4.3%20%E4%BB%A5%E5%86%99%E6%96%B9%E5%BC%8F%E6%89%93%E5%BC%80%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%EF%BC%88O_WRONLY%EF%BC%89-toc\" style=\"margin-left:40px\">4.3 \u4ee5\u5199\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff08;O_WRONLY&#xff09;<\/p>\n<p id=\"4.3.1%20%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88%E9%BB%98%E8%AE%A4%EF%BC%8C%E4%BB%85%20O_WRONLY%EF%BC%89-toc\" style=\"margin-left:80px\">4.3.1 \u963b\u585e\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff0c;\u4ec5 O_WRONLY&#xff09;<\/p>\n<p id=\"4.3.2%20%E9%9D%9E%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88O_WRONLY%20%7C%20O_NONBLOCK%EF%BC%89-toc\" style=\"margin-left:80px\">4.3.2 \u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_WRONLY | O_NONBLOCK&#xff09;<\/p>\n<p id=\"4.4%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E6%89%93%E5%BC%80%E8%A7%84%E5%88%99%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:40px\">4.4 \u547d\u540d\u7ba1\u9053\u6253\u5f00\u89c4\u5219\u603b\u7ed3<\/p>\n<p id=\"4.5%20%E6%89%93%E5%BC%80%E8%A7%84%E5%88%99%E7%9A%84%E6%9C%AC%E8%B4%A8-toc\" style=\"margin-left:40px\">4.5 \u6253\u5f00\u89c4\u5219\u7684\u672c\u8d28<\/p>\n<p id=\"%E4%BA%94%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E8%AF%BB%E5%86%99%E8%A7%84%E5%88%99%EF%BC%9A%E5%AE%8C%E5%85%A8%E5%A4%8D%E7%94%A8%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93-toc\" style=\"margin-left:0px\">\u4e94\u3001\u547d\u540d\u7ba1\u9053\u7684\u8bfb\u5199\u89c4\u5219&#xff1a;\u5b8c\u5168\u590d\u7528\u533f\u540d\u7ba1\u9053<\/p>\n<p id=\"5.1%20%E6%97%A0%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%AF%BB%E6%97%B6%E7%9A%84%E8%AF%BB%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99-toc\" style=\"margin-left:40px\">5.1 \u65e0\u6570\u636e\u53ef\u8bfb\u65f6\u7684\u8bfb\u64cd\u4f5c\u89c4\u5219<\/p>\n<p id=\"5.2%20%E7%AE%A1%E9%81%93%E7%BC%93%E5%86%B2%E5%8C%BA%E5%86%99%E6%BB%A1%E6%97%B6%E7%9A%84%E5%86%99%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99-toc\" style=\"margin-left:40px\">5.2 \u7ba1\u9053\u7f13\u51b2\u533a\u5199\u6ee1\u65f6\u7684\u5199\u64cd\u4f5c\u89c4\u5219<\/p>\n<p id=\"5.3%20%E6%89%80%E6%9C%89%E5%86%99%E7%AB%AF%E5%85%B3%E9%97%AD%E5%90%8E%E7%9A%84%E8%AF%BB%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99-toc\" style=\"margin-left:40px\">5.3 \u6240\u6709\u5199\u7aef\u5173\u95ed\u540e\u7684\u8bfb\u64cd\u4f5c\u89c4\u5219<\/p>\n<p id=\"5.4%20%E6%89%80%E6%9C%89%E8%AF%BB%E7%AB%AF%E5%85%B3%E9%97%AD%E5%90%8E%E7%9A%84%E5%86%99%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99-toc\" style=\"margin-left:40px\">5.4 \u6240\u6709\u8bfb\u7aef\u5173\u95ed\u540e\u7684\u5199\u64cd\u4f5c\u89c4\u5219<\/p>\n<p id=\"5.5%20%E7%AE%A1%E9%81%93%E5%86%99%E5%85%A5%E7%9A%84%E5%8E%9F%E5%AD%90%E6%80%A7%E8%A7%84%E5%88%99-toc\" style=\"margin-left:40px\">5.5 \u7ba1\u9053\u5199\u5165\u7684\u539f\u5b50\u6027\u89c4\u5219<\/p>\n<p id=\"5.6%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E8%AF%BB%E5%86%99%E8%A7%84%E5%88%99%E7%9A%84%E6%A0%B8%E5%BF%83%E6%B3%A8%E6%84%8F%E7%82%B9-toc\" style=\"margin-left:40px\">5.6 \u547d\u540d\u7ba1\u9053\u8bfb\u5199\u89c4\u5219\u7684\u6838\u5fc3\u6ce8\u610f\u70b9<\/p>\n<p id=\"%E5%85%AD%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%AE%9E%E6%88%98%E5%BC%80%E5%8F%91%EF%BC%9A%E4%BB%8E%E5%9F%BA%E7%A1%80%E6%A1%88%E4%BE%8B%E5%88%B0%20Server-Client%20%E9%80%9A%E4%BF%A1-toc\" style=\"margin-left:0px\">\u516d\u3001\u547d\u540d\u7ba1\u9053\u7684\u5b9e\u6218\u5f00\u53d1&#xff1a;\u4ece\u57fa\u7840\u6848\u4f8b\u5230 Server-Client \u901a\u4fe1<\/p>\n<p id=\"6.1%20%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B%201%EF%BC%9A%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%9F%BA%E7%A1%80%E8%AF%BB%E5%86%99-toc\" style=\"margin-left:40px\">6.1 \u5b9e\u6218\u6848\u4f8b 1&#xff1a;\u547d\u540d\u7ba1\u9053\u57fa\u7840\u8bfb\u5199<\/p>\n<p id=\"6.1.1%20%E5%86%99%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_write.c-toc\" style=\"margin-left:80px\">6.1.1 \u5199\u7aef\u7a0b\u5e8f&#xff1a;fifo_write.c<\/p>\n<p id=\"6.1.2%20%E8%AF%BB%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_read.c-toc\" style=\"margin-left:80px\">6.1.2 \u8bfb\u7aef\u7a0b\u5e8f&#xff1a;fifo_read.c<\/p>\n<p id=\"6.1.3%20%E7%BC%96%E8%AF%91%E4%B8%8E%E8%BF%90%E8%A1%8C-toc\" style=\"margin-left:80px\">6.1.3 \u7f16\u8bd1\u4e0e\u8fd0\u884c<\/p>\n<p id=\"6.1.4%20%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%E5%88%86%E6%9E%90-toc\" style=\"margin-left:80px\">6.1.4 \u8fd0\u884c\u7ed3\u679c\u5206\u6790<\/p>\n<p id=\"6.2%20%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B%202%EF%BC%9A%E5%9F%BA%E4%BA%8E%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%AE%9E%E7%8E%B0%E6%96%87%E4%BB%B6%E6%8B%B7%E8%B4%9D-toc\" style=\"margin-left:40px\">6.2 \u5b9e\u6218\u6848\u4f8b 2&#xff1a;\u57fa\u4e8e\u547d\u540d\u7ba1\u9053\u5b9e\u73b0\u6587\u4ef6\u62f7\u8d1d<\/p>\n<p id=\"6.2.1%20%E5%8F%91%E9%80%81%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_copy_send.c-toc\" style=\"margin-left:80px\">6.2.1 \u53d1\u9001\u7aef\u7a0b\u5e8f&#xff1a;fifo_copy_send.c<\/p>\n<p id=\"6.2.2%20%E6%8E%A5%E6%94%B6%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_copy_recv.c-toc\" style=\"margin-left:80px\">6.2.2 \u63a5\u6536\u7aef\u7a0b\u5e8f&#xff1a;fifo_copy_recv.c<\/p>\n<p id=\"6.2.3%20%E6%B5%8B%E8%AF%95%E6%AD%A5%E9%AA%A4-toc\" style=\"margin-left:80px\">6.2.3 \u6d4b\u8bd5\u6b65\u9aa4<\/p>\n<p id=\"6.2.4%20%E6%A1%88%E4%BE%8B%E6%A0%B8%E5%BF%83%E4%BA%AE%E7%82%B9-toc\" style=\"margin-left:80px\">6.2.4 \u6848\u4f8b\u6838\u5fc3\u4eae\u70b9<\/p>\n<p id=\"6.3%20%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B%203%EF%BC%9A%E5%9F%BA%E4%BA%8E%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%AE%9E%E7%8E%B0%20Server-Client%20%E9%80%9A%E4%BF%A1-toc\" style=\"margin-left:40px\">6.3 \u5b9e\u6218\u6848\u4f8b 3&#xff1a;\u57fa\u4e8e\u547d\u540d\u7ba1\u9053\u5b9e\u73b0 Server-Client \u901a\u4fe1<\/p>\n<p id=\"6.3.1%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9AserverPipe.c-toc\" style=\"margin-left:80px\">6.3.1 \u670d\u52a1\u7aef\u7a0b\u5e8f&#xff1a;serverPipe.c<\/p>\n<p id=\"6.3.2%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9AclientPipe.c-toc\" style=\"margin-left:80px\">6.3.2 \u5ba2\u6237\u7aef\u7a0b\u5e8f&#xff1a;clientPipe.c<\/p>\n<p id=\"6.3.3%20%E7%BC%96%E8%AF%91%E4%B8%8E%E8%BF%90%E8%A1%8C-toc\" style=\"margin-left:80px\">6.3.3 \u7f16\u8bd1\u4e0e\u8fd0\u884c<\/p>\n<p id=\"6.3.4%20%E6%A1%88%E4%BE%8B%E6%A0%B8%E5%BF%83%E4%BA%AE%E7%82%B9-toc\" style=\"margin-left:80px\">6.3.4 \u6848\u4f8b\u6838\u5fc3\u4eae\u70b9<\/p>\n<p id=\"%E4%B8%83%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E7%89%B9%E7%82%B9%E4%B8%8E%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF-toc\" style=\"margin-left:0px\">\u4e03\u3001\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u7279\u70b9\u4e0e\u4f7f\u7528\u573a\u666f<\/p>\n<p id=\"7.1%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E7%89%B9%E7%82%B9-toc\" style=\"margin-left:40px\">7.1 \u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u7279\u70b9<\/p>\n<p id=\"7.2%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%85%B8%E5%9E%8B%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF-toc\" style=\"margin-left:40px\">7.2 \u547d\u540d\u7ba1\u9053\u7684\u5178\u578b\u4f7f\u7528\u573a\u666f<\/p>\n<p id=\"7.3%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%B1%80%E9%99%90%E6%80%A7-toc\" style=\"margin-left:40px\">7.3 \u547d\u540d\u7ba1\u9053\u7684\u5c40\u9650\u6027<\/p>\n<p id=\"7.4%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E4%B8%8E%E5%85%B6%E4%BB%96%20IPC%20%E6%96%B9%E5%BC%8F%E7%9A%84%E5%AF%B9%E6%AF%94-toc\" style=\"margin-left:40px\">7.4 \u547d\u540d\u7ba1\u9053\u4e0e\u5176\u4ed6 IPC \u65b9\u5f0f\u7684\u5bf9\u6bd4<\/p>\n<p id=\"%E5%85%AB%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%BC%80%E5%8F%91%E7%9A%84%E9%81%BF%E5%9D%91%E6%8C%87%E5%8D%97-toc\" style=\"margin-left:0px\">\u516b\u3001\u547d\u540d\u7ba1\u9053\u5f00\u53d1\u7684\u907f\u5751\u6307\u5357<\/p>\n<p id=\"8.1%20%E5%9D%91%201%EF%BC%9A%E6%9C%AA%E5%A4%84%E7%90%86%20SIGPIPE%20%E4%BF%A1%E5%8F%B7%EF%BC%8C%E5%AF%BC%E8%87%B4%E8%BF%9B%E7%A8%8B%E6%84%8F%E5%A4%96%E9%80%80%E5%87%BA-toc\" style=\"margin-left:40px\">8.1 \u5751 1&#xff1a;\u672a\u5904\u7406 SIGPIPE \u4fe1\u53f7&#xff0c;\u5bfc\u81f4\u8fdb\u7a0b\u610f\u5916\u9000\u51fa<\/p>\n<p id=\"8.2%20%E5%9D%91%202%EF%BC%9A%E9%9D%9E%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%E4%B8%8B%EF%BC%8C%E9%94%99%E8%AF%AF%E5%88%A4%E6%96%AD%E4%B8%8D%E4%B8%A5%E8%B0%A8-toc\" style=\"margin-left:40px\">8.2 \u5751 2&#xff1a;\u975e\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u9519\u8bef\u5224\u65ad\u4e0d\u4e25\u8c28<\/p>\n<p id=\"8.3%20%E5%9D%91%203%EF%BC%9A%E5%A4%9A%E8%BF%9B%E7%A8%8B%E5%86%99%E7%AE%A1%E9%81%93%E6%97%B6%EF%BC%8C%E6%95%B0%E6%8D%AE%E6%B7%B7%E4%B9%B1-toc\" style=\"margin-left:40px\">8.3 \u5751 3&#xff1a;\u591a\u8fdb\u7a0b\u5199\u7ba1\u9053\u65f6&#xff0c;\u6570\u636e\u6df7\u4e71<\/p>\n<p id=\"8.4%20%E5%9D%91%204%EF%BC%9A%E5%8F%8C%E5%90%91%E9%80%9A%E4%BF%A1%E6%97%B6%EF%BC%8C%E5%8F%AA%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E7%AE%A1%E9%81%93%EF%BC%8C%E5%AF%BC%E8%87%B4%E6%AD%BB%E9%94%81-toc\" style=\"margin-left:40px\">8.4 \u5751 4&#xff1a;\u53cc\u5411\u901a\u4fe1\u65f6&#xff0c;\u53ea\u521b\u5efa\u4e00\u4e2a\u7ba1\u9053&#xff0c;\u5bfc\u81f4\u6b7b\u9501<\/p>\n<p id=\"8.5%20%E5%9D%91%205%EF%BC%9AFIFO%20%E6%96%87%E4%BB%B6%E6%9C%AA%E5%88%A0%E9%99%A4%EF%BC%8C%E5%AF%BC%E8%87%B4%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%90%AF%E6%97%B6%20mkfifo%20%E6%8A%A5%E9%94%99-toc\" style=\"margin-left:40px\">8.5 \u5751 5&#xff1a;FIFO \u6587\u4ef6\u672a\u5220\u9664&#xff0c;\u5bfc\u81f4\u7a0b\u5e8f\u91cd\u542f\u65f6 mkfifo \u62a5\u9519<\/p>\n<p id=\"8.6%20%E5%9D%91%206%EF%BC%9A%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%E4%B8%8B%EF%BC%8C%E8%BF%9B%E7%A8%8B%E5%8D%A1%E6%AD%BB%EF%BC%8C%E6%97%A0%E6%B3%95%E9%80%80%E5%87%BA-toc\" style=\"margin-left:40px\">8.6 \u5751 6&#xff1a;\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u8fdb\u7a0b\u5361\u6b7b&#xff0c;\u65e0\u6cd5\u9000\u51fa<\/p>\n<p id=\"%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:0px\">\u603b\u7ed3<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 style=\"background-color:transparent\">\u524d\u8a00<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728 Linux \u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u5b66\u4e60\u4e2d&#xff0c;\u533f\u540d\u7ba1\u9053\u4f5c\u4e3a\u5165\u95e8\u7ea7\u7684 IPC \u65b9\u5f0f&#xff0c;\u8ba9\u6211\u4eec\u7406\u89e3\u4e86 \u201c\u5185\u6838\u7f13\u51b2\u533a &#043; \u4e00\u5207\u7686\u6587\u4ef6\u201d \u7684\u8bbe\u8ba1\u601d\u60f3&#xff0c;\u4f46\u5b83\u6709\u4e00\u4e2a\u81f4\u547d\u7684\u9650\u5236 \u2014\u2014\u53ea\u80fd\u7528\u4e8e\u5177\u6709\u4eb2\u7f18\u5173\u7cfb\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1\u3002\u800c\u547d\u540d\u7ba1\u9053&#xff08;FIFO&#xff09;\u4f5c\u4e3a\u533f\u540d\u7ba1\u9053\u7684 \u201c\u5347\u7ea7\u7248\u201d&#xff0c;\u5b8c\u7f8e\u7a81\u7834\u4e86\u8fd9\u4e00\u9650\u5236&#xff0c;\u8ba9\u4efb\u610f\u65e0\u4eb2\u7f18\u5173\u7cfb\u7684\u8fdb\u7a0b\u4e5f\u80fd\u5b9e\u73b0\u9ad8\u6548\u7684\u7ba1\u9053\u901a\u4fe1\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u4e5f\u53eb<span style=\"color:#956fe7\"> FIFO&#xff08;First In First Out&#xff09;<\/span>&#xff0c;\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7ba1\u9053\u6587\u4ef6&#xff0c;\u5b83\u62e5\u6709\u78c1\u76d8\u7ea7\u7684\u6587\u4ef6\u540d&#xff0c;\u901a\u8fc7\u6587\u4ef6\u7cfb\u7edf\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u7684\u5173\u8054&#xff0c;\u64cd\u4f5c\u63a5\u53e3\u4e0e\u533f\u540d\u7ba1\u9053\u5b8c\u5168\u517c\u5bb9&#xff0c;\u5374\u80fd\u8986\u76d6\u66f4\u5e7f\u6cdb\u7684\u901a\u4fe1\u573a\u666f\u3002\u672c\u6587\u5c06\u4ece\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u6982\u5ff5\u51fa\u53d1&#xff0c;\u4e00\u6b65\u6b65\u62c6\u89e3\u5176\u539f\u7406\u3001\u521b\u5efa\u65b9\u5f0f\u3001\u6253\u5f00\u89c4\u5219\u3001\u5b9e\u6218\u5e94\u7528&#xff0c;\u7ed3\u5408\u786c\u6838\u4ee3\u7801\u548c\u901a\u4fd7\u8bb2\u89e3&#xff0c;\u8ba9\u4f60\u5f7b\u5e95\u5403\u900f\u547d\u540d\u7ba1\u9053&#xff0c;\u638c\u63e1\u8de8\u8fdb\u7a0b\u901a\u4fe1\u7684\u5173\u952e\u6280\u80fd\u3002\u4e0b\u9762\u5c31\u8ba9\u6211\u4eec\u6b63\u5f0f\u5f00\u59cb\u5427&#xff01;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"870\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260211035748-698bfe3cbdb86.png\" width=\"1296\" \/><\/p>\n<hr \/>\n<h2 id=\"%E4%B8%80%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E8%AF%9E%E7%94%9F%EF%BC%9A%E8%A7%A3%E5%86%B3%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E7%97%9B%E7%82%B9\">\u4e00\u3001\u547d\u540d\u7ba1\u9053\u7684\u8bde\u751f&#xff1a;\u89e3\u51b3\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u75db\u70b9<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u5b66\u4e60\u547d\u540d\u7ba1\u9053\u4e4b\u524d&#xff0c;\u6211\u4eec\u5148\u56de\u987e\u4e00\u4e0b\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u5c40\u9650\u6027&#xff0c;\u8fd9\u4e5f\u662f\u547d\u540d\u7ba1\u9053\u8bde\u751f\u7684\u6839\u672c\u539f\u56e0\u3002<\/p>\n<h3 id=\"1.1%20%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E8%87%B4%E5%91%BD%E7%9F%AD%E6%9D%BF\">1.1 \u533f\u540d\u7ba1\u9053\u7684\u81f4\u547d\u77ed\u677f<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u533f\u540d\u7ba1\u9053\u57fa\u4e8e\u6587\u4ef6\u63cf\u8ff0\u7b26\u7ee7\u627f\u5b9e\u73b0\u901a\u4fe1&#xff0c;\u53ea\u6709\u901a\u8fc7fork()\u521b\u5efa\u7684\u5b50\u8fdb\u7a0b&#xff08;\u6216\u5144\u5f1f\u8fdb\u7a0b&#xff09;\u624d\u80fd\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684\u7ba1\u9053\u63cf\u8ff0\u7b26&#xff0c;\u56e0\u6b64\u53ea\u80fd\u7528\u4e8e\u6709\u5171\u540c\u7956\u5148\u7684\u4eb2\u7f18\u8fdb\u7a0b&#xff08;\u7236 \/ \u5b50\u3001\u5144 \/ \u5f1f&#xff09;\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4f46\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u66f4\u591a\u7684\u9700\u6c42\u662f\u8ba9\u5b8c\u5168\u72ec\u7acb\u7684\u65e0\u4eb2\u7f18\u8fdb\u7a0b\u901a\u4fe1&#xff1a;\u6bd4\u5982\u4e00\u4e2a\u670d\u52a1\u8fdb\u7a0b\u548c\u4e00\u4e2a\u5ba2\u6237\u7aef\u8fdb\u7a0b\u3001\u4e24\u4e2a\u72ec\u7acb\u542f\u52a8\u7684\u5e94\u7528\u7a0b\u5e8f\u3001\u4e0d\u540c\u7528\u6237\u7684\u8fdb\u7a0b\u4e4b\u95f4&#xff0c;\u6b64\u65f6\u533f\u540d\u7ba1\u9053\u5c31\u5b8c\u5168\u65e0\u6cd5\u6ee1\u8db3\u9700\u6c42\u3002<\/p>\n<h3 id=\"1.2%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E8%AE%BE%E8%AE%A1%E6%80%9D%E8%B7%AF\">1.2 \u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8bbe\u8ba1\u601d\u8def<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e3a\u4e86\u89e3\u51b3\u533f\u540d\u7ba1\u9053\u7684\u4eb2\u7f18\u9650\u5236\u95ee\u9898&#xff0c;Linux \u8bbe\u8ba1\u8005\u5728\u533f\u540d\u7ba1\u9053\u7684\u57fa\u7840\u4e0a&#xff0c;\u589e\u52a0\u4e86\u6587\u4ef6\u7cfb\u7edf\u7684\u6807\u8bc6&#xff0c;\u4e5f\u5c31\u662f\u547d\u540d\u7ba1\u9053\u6587\u4ef6\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8bbe\u8ba1\u601d\u8def\u53ef\u4ee5\u603b\u7ed3\u4e3a&#xff1a;\u7ed9\u5185\u6838\u4e2d\u7684\u7ba1\u9053\u7f13\u51b2\u533a&#xff0c;\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u6587\u4ef6\u540d&#xff0c;\u4efb\u4f55\u8fdb\u7a0b\u53ea\u8981\u80fd\u8bbf\u95ee\u8fd9\u4e2a\u6587\u4ef6&#xff0c;\u5c31\u80fd\u901a\u8fc7\u5b83\u8fde\u63a5\u5230\u5185\u6838\u4e2d\u7684\u7ba1\u9053\u7f13\u51b2\u533a&#xff0c;\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7b80\u5355\u6765\u8bf4&#xff0c;\u533f\u540d\u7ba1\u9053\u662f \u201c\u65e0\u540d\u7684\u5185\u6838\u7f13\u51b2\u533a\u201d&#xff0c;\u53ea\u6709\u4eb2\u7f18\u8fdb\u7a0b\u80fd\u627e\u5230&#xff1b;\u547d\u540d\u7ba1\u9053\u662f \u201c\u6709\u540d\u7684\u5185\u6838\u7f13\u51b2\u533a\u201d&#xff0c;\u4efb\u4f55\u8fdb\u7a0b\u53ea\u8981\u77e5\u9053\u6587\u4ef6\u540d&#xff0c;\u5c31\u80fd\u627e\u5230\u5e76\u4f7f\u7528\u3002<\/p>\n<h3 id=\"1.3%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E4%B8%8E%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E5%85%B3%E8%81%94\">1.3 \u547d\u540d\u7ba1\u9053\u4e0e\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u5173\u8054<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u662f\u533f\u540d\u7ba1\u9053\u7684\u8d85\u96c6&#xff0c;\u4e8c\u8005\u7684\u5185\u6838\u5b9e\u73b0\u548c\u64cd\u4f5c\u8bed\u4e49\u5b8c\u5168\u4e00\u81f4&#xff1a;<\/p>\n<ul>\n<li>\u5e95\u5c42\u90fd\u662f\u5185\u6838\u7ef4\u62a4\u7684\u5355\u5411\u5b57\u8282\u6d41\u7f13\u51b2\u533a&#xff1b;<\/li>\n<li>\u90fd\u9075\u5faa\u76f8\u540c\u7684\u8bfb\u5199\u89c4\u5219&#xff08;\u963b\u585e \/ \u975e\u963b\u585e\u3001\u539f\u5b50\u5199\u5165\u3001SIGPIPE \u4fe1\u53f7\u7b49&#xff09;&#xff1b;<\/li>\n<li>\u90fd\u4f7f\u7528<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">read()<\/span><span style=\"background-color:#fbd4d0\">\/<\/span><span style=\"background-color:#fbd4d0\">write()<\/span><span style=\"background-color:#fbd4d0\">\/<\/span><span style=\"background-color:#fbd4d0\">close()<\/span><\/span>\u7b49\u6807\u51c6\u6587\u4ef6\u64cd\u4f5c\u63a5\u53e3&#xff1b;<\/li>\n<li>\u90fd\u662f\u534a\u53cc\u5de5\u901a\u4fe1&#xff0c;\u53cc\u5411\u901a\u4fe1\u9700\u8981\u521b\u5efa\u4e24\u4e2a\u7ba1\u9053\u3002<\/li>\n<\/ul>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e8c\u8005\u7684\u552f\u4e00\u533a\u522b\u4ec5\u5728\u4e8e\u521b\u5efa\u548c\u6253\u5f00\u7684\u65b9\u5f0f&#xff1a;<\/p>\n<ul>\n<li>\u533f\u540d\u7ba1\u9053\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">pipe()<\/span><\/span>\u51fd\u6570\u521b\u5efa&#xff0c;\u521b\u5efa\u5373\u6253\u5f00&#xff0c;\u8fd4\u56de\u4e24\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1b;<\/li>\n<li>\u547d\u540d\u7ba1\u9053\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo()<\/span><\/span>\u51fd\u6570\u521b\u5efa&#xff08;\u751f\u6210\u7ba1\u9053\u6587\u4ef6&#xff09;&#xff0c;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">open()<\/span><\/span>\u51fd\u6570\u6253\u5f00&#xff0c;\u83b7\u53d6\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/li>\n<\/ul>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u53ef\u4ee5\u8bf4&#xff0c;\u53ea\u8981\u638c\u63e1\u4e86\u533f\u540d\u7ba1\u9053&#xff0c;\u5b66\u4e60\u547d\u540d\u7ba1\u9053\u53ea\u9700\u8981\u91cd\u70b9\u638c\u63e1\u521b\u5efa\u548c\u6253\u5f00\u8fd9\u4e24\u4e2a\u65b0\u64cd\u4f5c&#xff0c;\u5176\u4f59\u5185\u5bb9\u5b8c\u5168\u53ef\u4ee5\u590d\u7528\u3002<\/p>\n<\/p>\n<h2 id=\"%E4%BA%8C%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E8%AE%A4%E7%9F%A5%EF%BC%9A%E4%BB%80%E4%B9%88%E6%98%AF%20FIFO%20%E6%96%87%E4%BB%B6%EF%BC%9F\">\u4e8c\u3001\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8ba4\u77e5&#xff1a;\u4ec0\u4e48\u662f FIFO \u6587\u4ef6&#xff1f;<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u662fFIFO \u6587\u4ef6&#xff0c;\u8fd9\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u6587\u4ef6\u7c7b\u578b&#xff0c;\u4e0e\u666e\u901a\u6587\u4ef6\u3001\u76ee\u5f55\u3001\u8bbe\u5907\u6587\u4ef6\u5e76\u5217&#xff0c;\u5b58\u5728\u4e8e Linux \u7684\u6587\u4ef6\u7cfb\u7edf\u4e2d&#xff0c;\u4f46\u53c8\u6709\u5176\u72ec\u7279\u7684\u5c5e\u6027\u3002<\/p>\n<h3 id=\"2.1%20FIFO%20%E6%96%87%E4%BB%B6%E7%9A%84%E6%9C%AC%E8%B4%A8\">2.1 FIFO \u6587\u4ef6\u7684\u672c\u8d28<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0FIFO \u6587\u4ef6\u4ec5\u4f5c\u4e3a\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684 \u201c\u6807\u8bc6\u201d&#xff0c;\u5b83\u672c\u8eab\u4e0d\u5b58\u50a8\u4efb\u4f55\u6570\u636e&#xff0c;\u6570\u636e\u4f9d\u65e7\u5b58\u50a8\u5728\u5185\u6838\u7684\u7ba1\u9053\u7f13\u51b2\u533a\u4e2d\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f53\u8fdb\u7a0b\u5bf9 FIFO \u6587\u4ef6\u6267\u884c<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">read()<\/span><span style=\"background-color:#fbd4d0\">\/<\/span><span style=\"background-color:#fbd4d0\">write()<\/span><\/span>\u64cd\u4f5c\u65f6&#xff0c;\u5b9e\u9645\u4e0a\u662f\u5bf9\u5185\u6838\u4e2d\u7684\u7ba1\u9053\u7f13\u51b2\u533a\u8fdb\u884c\u64cd\u4f5c&#xff0c;FIFO \u6587\u4ef6\u53ea\u662f\u4e00\u4e2a \u201c\u5165\u53e3\u201d\u3002\u8fdb\u7a0b\u9000\u51fa\u540e&#xff0c;FIFO \u6587\u4ef6\u4f1a\u4fdd\u7559\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d&#xff08;\u9664\u975e\u624b\u52a8\u5220\u9664&#xff09;&#xff0c;\u4f46\u5185\u6838\u4e2d\u7684\u7ba1\u9053\u7f13\u51b2\u533a\u4f1a\u88ab\u91ca\u653e&#xff0c;\u6570\u636e\u4e5f\u4f1a\u4e22\u5931\u3002<\/p>\n<h3 id=\"2.2%20FIFO%20%E6%96%87%E4%BB%B6%E7%9A%84%E6%A0%87%E8%AF%86\">2.2 FIFO \u6587\u4ef6\u7684\u6807\u8bc6<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728 Linux \u4e2d&#xff0c;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">ls -l<\/span><\/span>\u547d\u4ee4\u67e5\u770b\u6587\u4ef6\u65f6&#xff0c;FIFO \u6587\u4ef6\u7684\u6587\u4ef6\u7c7b\u578b\u6807\u8bc6\u4e3a p&#xff08;pipe \u7684\u9996\u5b57\u6bcd&#xff09;&#xff0c;\u8fd9\u662f\u533a\u5206 FIFO \u6587\u4ef6\u548c\u5176\u4ed6\u6587\u4ef6\u7684\u5173\u952e\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4f8b\u5982&#xff0c;\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amypipe\u7684\u547d\u540d\u7ba1\u9053\u540e&#xff0c;\u6267\u884cls -l\u4f1a\u770b\u5230\u5982\u4e0b\u7ed3\u679c&#xff1a;<\/p>\n<p>prw-r&#8211;r&#8211; 1 root root 0 2\u6708  11 15:00 mypipe<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>p&#xff1a;\u8868\u793a\u6587\u4ef6\u7c7b\u578b\u4e3a\u547d\u540d\u7ba1\u9053&#xff08;FIFO&#xff09;&#xff1b;<\/li>\n<li>\u5927\u5c0f\u4e3a0&#xff1a;\u56e0\u4e3a FIFO \u6587\u4ef6\u4e0d\u5b58\u50a8\u6570\u636e&#xff0c;\u4ec5\u4f5c\u4e3a\u6807\u8bc6&#xff1b;<\/li>\n<li>\u6743\u9650\u4f4d\u4e0e\u666e\u901a\u6587\u4ef6\u4e00\u81f4&#xff08;\u5982rw-r&#8211;r&#8211;&#xff09;&#xff0c;\u7528\u4e8e\u63a7\u5236\u8fdb\u7a0b\u5bf9\u7ba1\u9053\u7684\u8bbf\u95ee\u6743\u9650\u3002<\/li>\n<\/ul>\n<h3 id=\"2.3%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E9%80%9A%E4%BF%A1%E6%A8%A1%E5%9E%8B\">2.3 \u547d\u540d\u7ba1\u9053\u7684\u901a\u4fe1\u6a21\u578b<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u901a\u4fe1\u6a21\u578b\u975e\u5e38\u7b80\u5355&#xff0c;\u6838\u5fc3\u5206\u4e3a\u4e09\u6b65&#xff1a;<\/p>\n<li>\u521b\u5efa FIFO \u6587\u4ef6&#xff1a;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo()<\/span><\/span>\u6216\u547d\u4ee4\u884c\u521b\u5efa\u4e00\u4e2a FIFO \u6587\u4ef6&#xff0c;\u4f5c\u4e3a\u7ba1\u9053\u7684\u6807\u8bc6&#xff1b;<\/li>\n<li>\u8fdb\u7a0b\u6253\u5f00 FIFO \u6587\u4ef6&#xff1a;\u901a\u4fe1\u7684\u53cc\u65b9\u8fdb\u7a0b\u5206\u522b\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">open()<\/span><\/span>\u51fd\u6570\u6253\u5f00\u8be5 FIFO \u6587\u4ef6&#xff0c;\u83b7\u53d6\u8bfb \/ \u5199\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1b;<\/li>\n<li>\u8fdb\u7a0b\u95f4\u901a\u4fe1&#xff1a;\u4e00\u4e2a\u8fdb\u7a0b\u5411 FIFO \u6587\u4ef6\u5199\u5165\u6570\u636e&#xff08;\u5b9e\u9645\u5199\u5165\u5185\u6838\u7f13\u51b2\u533a&#xff09;&#xff0c;\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u4ece FIFO \u6587\u4ef6\u8bfb\u53d6\u6570\u636e&#xff08;\u5b9e\u9645\u4ece\u5185\u6838\u7f13\u51b2\u533a\u8bfb\u53d6&#xff09;&#xff0c;\u5b9e\u73b0\u6570\u636e\u4f20\u8f93\u3002<\/li>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6574\u4e2a\u8fc7\u7a0b\u4e2d&#xff0c;FIFO \u6587\u4ef6\u5c31\u50cf\u4e00\u4e2a \u201c\u6865\u6881\u201d&#xff0c;\u8fde\u63a5\u4e86\u4e24\u4e2a\u65e0\u4eb2\u7f18\u8fdb\u7a0b\u548c\u5185\u6838\u4e2d\u7684\u7ba1\u9053\u7f13\u51b2\u533a&#xff0c;\u7a81\u7834\u4e86\u533f\u540d\u7ba1\u9053\u7684\u4eb2\u7f18\u9650\u5236\u3002<\/p>\n<\/p>\n<h2 id=\"%E4%B8%89%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%88%9B%E5%BB%BA%EF%BC%9Amkfifo%20()%20%E5%87%BD%E6%95%B0%E4%B8%8E%E5%91%BD%E4%BB%A4%E8%A1%8C\">\u4e09\u3001\u547d\u540d\u7ba1\u9053\u7684\u521b\u5efa&#xff1a;mkfifo () \u51fd\u6570\u4e0e\u547d\u4ee4\u884c<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u6709\u4e24\u79cd\u521b\u5efa\u65b9\u5f0f&#xff1a;\u547d\u4ee4\u884c\u521b\u5efa\u548c\u7a0b\u5e8f\u4e2d\u901a\u8fc7 mkfifo () \u51fd\u6570\u521b\u5efa&#xff0c;\u524d\u8005\u9002\u7528\u4e8e\u6d4b\u8bd5\u548c\u624b\u52a8\u64cd\u4f5c&#xff0c;\u540e\u8005\u9002\u7528\u4e8e\u7a0b\u5e8f\u5f00\u53d1&#xff0c;\u4e8c\u8005\u7684\u6548\u679c\u5b8c\u5168\u4e00\u81f4\u3002<\/p>\n<h3 id=\"3.1%20%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%88%9B%E5%BB%BA%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93\">3.1 \u547d\u4ee4\u884c\u521b\u5efa\u547d\u540d\u7ba1\u9053<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728 Linux \u7ec8\u7aef\u4e2d&#xff0c;\u76f4\u63a5\u4f7f\u7528<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo<\/span><\/span>\u547d\u4ee4\u5373\u53ef\u521b\u5efa\u547d\u540d\u7ba1\u9053&#xff0c;\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/p>\n<p># mkfifo [\u9009\u9879] \u7ba1\u9053\u6587\u4ef6\u540d<br \/>\nmkfifo mypipe<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5e38\u7528\u9009\u9879&#xff1a;<\/p>\n<ul>\n<li>-m&#xff1a;\u6307\u5b9a\u7ba1\u9053\u6587\u4ef6\u7684\u6743\u9650&#xff0c;\u5982<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo -m 0644 mypipe<\/span><\/span>&#xff1b;<\/li>\n<li>\u4e0d\u6307\u5b9a\u6743\u9650\u65f6&#xff0c;\u9ed8\u8ba4\u6743\u9650\u7531umask\u51b3\u5b9a&#xff08;\u901a\u5e38\u4e3a 0666 &amp; ~umask&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u521b\u5efa\u540e&#xff0c;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">ls -l<\/span><\/span>\u5373\u53ef\u770b\u5230\u6807\u8bc6\u4e3ap\u7684 FIFO \u6587\u4ef6&#xff0c;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">rm \u7ba1\u9053\u6587\u4ef6\u540d<\/span><\/span>\u5373\u53ef\u5220\u9664\u8be5\u6587\u4ef6\u3002<\/p>\n<h3 id=\"3.2%20%E7%A8%8B%E5%BA%8F%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%EF%BC%9Amkfifo%20()%20%E5%87%BD%E6%95%B0\">3.2 \u7a0b\u5e8f\u4e2d\u521b\u5efa\u547d\u540d\u7ba1\u9053&#xff1a;mkfifo () \u51fd\u6570<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728 C\/C&#043;&#043; \u7a0b\u5e8f\u4e2d&#xff0c;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo()<\/span><\/span>\u51fd\u6570\u521b\u5efa\u547d\u540d\u7ba1\u9053&#xff0c;\u8fd9\u662f\u5f00\u53d1\u4e2d\u7684\u4e3b\u6d41\u65b9\u5f0f&#xff0c;\u51fd\u6570\u539f\u578b\u5b9a\u4e49\u5728<span style=\"color:#956fe7\">&lt;sys\/stat.h&gt;<\/span>\u5934\u6587\u4ef6\u4e2d\u3002<\/p>\n<h4 id=\"3.2.1%20mkfifo%20()%20%E5%87%BD%E6%95%B0%E6%8E%A5%E5%8F%A3\">3.2.1 mkfifo () \u51fd\u6570\u63a5\u53e3<\/h4>\n<p>#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<\/p>\n<p>\/\/ \u529f\u80fd&#xff1a;\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u7ba1\u9053&#xff08;FIFO\u6587\u4ef6&#xff09;<br \/>\n\/\/ \u53c2\u6570&#xff1a;<br \/>\n\/\/   pathname &#8211; \u7ba1\u9053\u6587\u4ef6\u7684\u8def\u5f84&#043;\u540d\u79f0&#xff0c;\u5982&#034;.\/mypipe&#034;<br \/>\n\/\/   mode     &#8211; \u7ba1\u9053\u6587\u4ef6\u7684\u6743\u9650&#xff0c;\u59820644\u30010666&#xff0c;\u4e0eopen()\u51fd\u6570\u7684mode\u53c2\u6570\u4e00\u81f4<br \/>\n\/\/ \u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de0&#xff0c;\u5931\u8d25\u8fd4\u56de-1&#xff0c;\u5e76\u8bbe\u7f6eerrno<br \/>\nint mkfifo(const char *pathname, mode_t mode);<\/p>\n<h4 id=\"3.2.2%20%E6%A0%B8%E5%BF%83%E6%B3%A8%E6%84%8F%E7%82%B9\">3.2.2 \u6838\u5fc3\u6ce8\u610f\u70b9<\/h4>\n<li>\u6743\u9650\u8ba1\u7b97&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo()<\/span><\/span>\u7684mode\u53c2\u6570\u4f1a\u4e0e\u5f53\u524d\u8fdb\u7a0b\u7684umask\u8fdb\u884c\u6309\u4f4d\u4e0e\u53d6\u53cd\u8fd0\u7b97&#xff0c;\u6700\u7ec8\u7684\u6587\u4ef6\u6743\u9650\u4e3a<span style=\"color:#956fe7\">mode &amp; ~umask<\/span>\u3002\u5982\u679c\u9700\u8981\u8ba9\u7ba1\u9053\u6587\u4ef6\u7684\u6743\u9650\u4e25\u683c\u7b49\u4e8emode&#xff0c;\u53ef\u4ee5\u5148\u901a\u8fc7umask(0)\u5c06\u63a9\u7801\u7f6e 0&#xff1b;<\/li>\n<li>\u6587\u4ef6\u5df2\u5b58\u5728&#xff1a;\u5982\u679c<span style=\"color:#956fe7\">pathname<\/span>\u6307\u5b9a\u7684 FIFO \u6587\u4ef6\u5df2\u5b58\u5728&#xff0c;\u518d\u6b21\u8c03\u7528<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo()<\/span><\/span>\u4f1a\u5931\u8d25&#xff0c;<span style=\"color:#956fe7\">errno<\/span>\u8bbe\u7f6e\u4e3a<span style=\"color:#956fe7\">EEXIST<\/span>&#xff1b;<\/li>\n<li>\u8def\u5f84\u5408\u6cd5\u6027&#xff1a;<span style=\"color:#956fe7\">pathname<\/span>\u6307\u5b9a\u7684\u76ee\u5f55\u5fc5\u987b\u5b58\u5728&#xff0c;\u5426\u5219\u4f1a\u5931\u8d25&#xff0c;<span style=\"color:#956fe7\">errno<\/span>\u8bbe\u7f6e\u4e3a<span style=\"color:#956fe7\">ENOENT<\/span>&#xff1b;<\/li>\n<li>FIFO \u6587\u4ef6\u4e0e\u666e\u901a\u6587\u4ef6&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo()<\/span><\/span>\u521b\u5efa\u7684\u662f FIFO \u6587\u4ef6&#xff0c;\u4e0d\u80fd\u521b\u5efa\u666e\u901a\u6587\u4ef6&#xff0c;\u4e5f\u4e0d\u80fd\u8986\u76d6\u5df2\u5b58\u5728\u7684\u666e\u901a\u6587\u4ef6\u3002<\/li>\n<h4 id=\"3.2.3%20%E7%AE%80%E5%8D%95%E5%88%9B%E5%BB%BA%E7%A4%BA%E4%BE%8B\">3.2.3 \u7b80\u5355\u521b\u5efa\u793a\u4f8b<\/h4>\n<p>#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;stdio.h&gt;<br \/>\n#include &lt;errno.h&gt;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/ \u5c06umask\u7f6e0&#xff0c;\u8ba9\u7ba1\u9053\u6743\u9650\u4e25\u683c\u4e3a0644<br \/>\n    umask(0);<br \/>\n    \/\/ \u521b\u5efa\u547d\u540d\u7ba1\u9053\u6587\u4ef6.\/mypipe&#xff0c;\u6743\u96500644<br \/>\n    if (mkfifo(&#034;.\/mypipe&#034;, 0644) &lt; 0)<br \/>\n    {<br \/>\n        perror(&#034;mkfifo error&#034;);<br \/>\n        return -1;<br \/>\n    }<br \/>\n    printf(&#034;\u547d\u540d\u7ba1\u9053\u521b\u5efa\u6210\u529f\\\\n&#034;);<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7f16\u8bd1\u8fd0\u884c\u8be5\u7a0b\u5e8f\u540e&#xff0c;\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u6267\u884c<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">ls &#8211;<\/span><\/span>l&#xff0c;\u5c31\u80fd\u770b\u5230prw-r&#8211;r&#8211;\u7684 FIFO \u6587\u4ef6mypipe\u3002<\/p>\n<\/p>\n<h2 id=\"%E5%9B%9B%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%89%93%E5%BC%80%E8%A7%84%E5%88%99%EF%BC%9A%E6%9C%80%E5%85%B3%E9%94%AE%E7%9A%84%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E7%82%B9\">\u56db\u3001\u547d\u540d\u7ba1\u9053\u7684\u6253\u5f00\u89c4\u5219&#xff1a;\u6700\u5173\u952e\u7684\u6838\u5fc3\u77e5\u8bc6\u70b9<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u6253\u5f00\u89c4\u5219\u662f\u5b66\u4e60\u7684\u91cd\u4e2d\u4e4b\u91cd&#xff0c;\u4e5f\u662f\u4e0e\u666e\u901a\u6587\u4ef6\u6253\u5f00\u7684\u6700\u5927\u533a\u522b&#xff0c;\u76f4\u63a5\u51b3\u5b9a\u4e86\u8fdb\u7a0b\u7684\u8fd0\u884c\u884c\u4e3a&#xff08;\u963b\u585e \/ \u975e\u963b\u585e&#xff09;\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u662f\u5355\u5411\u901a\u4fe1\u7684&#xff0c;\u5fc5\u987b\u6709\u4e00\u4e2a\u8fdb\u7a0b\u4ee5\u8bfb\u65b9\u5f0f\u6253\u5f00&#xff0c;\u4e00\u4e2a\u8fdb\u7a0b\u4ee5\u5199\u65b9\u5f0f\u6253\u5f00&#xff0c;\u5185\u6838\u624d\u4f1a\u5b8c\u6210\u7ba1\u9053\u7684\u521d\u59cb\u5316&#xff0c;\u5426\u5219\u6253\u5f00\u64cd\u4f5c\u4f1a\u6839\u636e\u662f\u5426\u8bbe\u7f6e\u975e\u963b\u585e\u6807\u5fd7\u4ea7\u751f\u4e0d\u540c\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u6253\u5f00\u89c4\u5219\u56f4\u7ed5<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">open()<\/span><\/span>\u51fd\u6570\u7684flags \u53c2\u6570\u5c55\u5f00&#xff0c;\u6838\u5fc3\u5206\u4e3a\u8bfb\u6253\u5f00\u548c\u5199\u6253\u5f00\u4e24\u79cd\u60c5\u51b5&#xff0c;\u6bcf\u79cd\u60c5\u51b5\u53c8\u5206\u4e3a\u963b\u585e\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff09;\u548c\u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_NONBLOCK&#xff09;\u3002<\/p>\n<h3 id=\"4.1%20open%20()%20%E5%87%BD%E6%95%B0%E7%9A%84%E6%A0%B8%E5%BF%83%E5%8F%82%E6%95%B0\">4.1 open () \u51fd\u6570\u7684\u6838\u5fc3\u53c2\u6570<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u901a\u8fc7\u6807\u51c6\u7684<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">open()<\/span><\/span>\u51fd\u6570\u6253\u5f00&#xff0c;\u51fd\u6570\u539f\u578b\u5982\u4e0b&#xff1a;<\/p>\n<p>#include &lt;fcntl.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<\/p>\n<p>int open(const char *pathname, int flags, mode_t mode);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5bf9\u4e8e\u547d\u540d\u7ba1\u9053&#xff0c;\u6838\u5fc3\u5173\u6ce8flags\u53c2\u6570&#xff0c;\u5e38\u7528\u53d6\u503c&#xff1a;<\/p>\n<ul>\n<li>O_RDONLY&#xff1a;\u4ee5\u53ea\u8bfb\u65b9\u5f0f\u6253\u5f00&#xff08;\u8bfb\u7aef&#xff09;&#xff1b;<\/li>\n<li>O_WRONLY&#xff1a;\u4ee5\u53ea\u5199\u65b9\u5f0f\u6253\u5f00&#xff08;\u5199\u7aef&#xff09;&#xff1b;<\/li>\n<li>O_NONBLOCK&#xff1a;\u975e\u963b\u585e\u6a21\u5f0f&#xff0c;\u4e0e <span style=\"color:#956fe7\">O_RDONLY\/O_WRONLY<\/span> \u914d\u5408\u4f7f\u7528&#xff08;\u5982 <span style=\"color:#956fe7\">O_RDONLY | O_NONBLOCK<\/span>&#xff09;&#xff1b;<\/li>\n<li>O_CREAT&#xff1a;\u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u521b\u5efa&#xff08;\u547d\u540d\u7ba1\u9053\u4e00\u822c\u5148\u901a\u8fc7 mkfifo () \u521b\u5efa&#xff0c;\u6b64\u53c2\u6570\u5f88\u5c11\u7528&#xff09;\u3002<\/li>\n<\/ul>\n<h3 id=\"4.2%20%E4%BB%A5%E8%AF%BB%E6%96%B9%E5%BC%8F%E6%89%93%E5%BC%80%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%EF%BC%88O_RDONLY%EF%BC%89\">4.2 \u4ee5\u8bfb\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff08;O_RDONLY&#xff09;<\/h3>\n<h4 id=\"4.2.1%20%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88%E9%BB%98%E8%AE%A4%EF%BC%8C%E4%BB%85%20O_RDONLY%EF%BC%89\">4.2.1 \u963b\u585e\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff0c;\u4ec5 O_RDONLY&#xff09;<\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u8fdb\u7a0b\u4ee5\u7eaf\u8bfb\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u4e14\u6b64\u65f6\u6ca1\u6709\u4efb\u4f55\u8fdb\u7a0b\u4ee5\u5199\u65b9\u5f0f\u6253\u5f00\u8be5\u7ba1\u9053&#xff0c;\u5219<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">open()<\/span><\/span>\u8c03\u7528\u4f1a\u963b\u585e&#xff0c;\u76f4\u5230\u6709\u8fdb\u7a0b\u4ee5\u5199\u65b9\u5f0f\u6253\u5f00\u8be5\u7ba1\u9053&#xff0c;\u624d\u4f1a\u8fd4\u56de\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7b80\u5355\u6765\u8bf4&#xff1a;\u8bfb\u7aef\u5148\u6253\u5f00&#xff0c;\u4f1a\u963b\u585e\u7b49\u5f85\u5199\u7aef\u6253\u5f00\u3002<\/p>\n<h4 id=\"4.2.2%20%E9%9D%9E%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88O_RDONLY%20%7C%20O_NONBLOCK%EF%BC%89\">4.2.2 \u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_RDONLY | O_NONBLOCK&#xff09;<\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u8fdb\u7a0b\u4ee5\u975e\u963b\u585e\u8bfb\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u65e0\u8bba\u6b64\u65f6\u662f\u5426\u6709\u8fdb\u7a0b\u4ee5\u5199\u65b9\u5f0f\u6253\u5f00\u8be5\u7ba1\u9053&#xff0c;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">open()<\/span><\/span>\u8c03\u7528\u90fd\u4f1a\u7acb\u523b\u8fd4\u56de\u6210\u529f&#xff0c;\u83b7\u53d6\u8bfb\u7aef\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/p>\n<h3 id=\"4.3%20%E4%BB%A5%E5%86%99%E6%96%B9%E5%BC%8F%E6%89%93%E5%BC%80%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%EF%BC%88O_WRONLY%EF%BC%89\">4.3 \u4ee5\u5199\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff08;O_WRONLY&#xff09;<\/h3>\n<h4 id=\"4.3.1%20%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88%E9%BB%98%E8%AE%A4%EF%BC%8C%E4%BB%85%20O_WRONLY%EF%BC%89\">4.3.1 \u963b\u585e\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff0c;\u4ec5 O_WRONLY&#xff09;<\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u8fdb\u7a0b\u4ee5\u7eaf\u5199\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u4e14\u6b64\u65f6\u6ca1\u6709\u4efb\u4f55\u8fdb\u7a0b\u4ee5\u8bfb\u65b9\u5f0f\u6253\u5f00\u8be5\u7ba1\u9053&#xff0c;\u5219open()\u8c03\u7528\u4f1a\u963b\u585e&#xff0c;\u76f4\u5230\u6709\u8fdb\u7a0b\u4ee5\u8bfb\u65b9\u5f0f\u6253\u5f00\u8be5\u7ba1\u9053&#xff0c;\u624d\u4f1a\u8fd4\u56de\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7b80\u5355\u6765\u8bf4&#xff1a;\u5199\u7aef\u5148\u6253\u5f00&#xff0c;\u4f1a\u963b\u585e\u7b49\u5f85\u8bfb\u7aef\u6253\u5f00\u3002<\/p>\n<h4 id=\"4.3.2%20%E9%9D%9E%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%EF%BC%88O_WRONLY%20%7C%20O_NONBLOCK%EF%BC%89\">4.3.2 \u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_WRONLY | O_NONBLOCK&#xff09;<\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u8fdb\u7a0b\u4ee5\u975e\u963b\u585e\u5199\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u4e14\u6b64\u65f6\u6ca1\u6709\u4efb\u4f55\u8fdb\u7a0b\u4ee5\u8bfb\u65b9\u5f0f\u6253\u5f00\u8be5\u7ba1\u9053&#xff0c;\u5219<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">open()<\/span><\/span>\u8c03\u7528\u4f1a\u7acb\u523b\u5931\u8d25&#xff0c;\u8fd4\u56de &#8211; 1&#xff0c;errno\u8bbe\u7f6e\u4e3aENXIO\u3002<\/p>\n<h3 id=\"4.4%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E6%89%93%E5%BC%80%E8%A7%84%E5%88%99%E6%80%BB%E7%BB%93\">4.4 \u547d\u540d\u7ba1\u9053\u6253\u5f00\u89c4\u5219\u603b\u7ed3<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e3a\u4e86\u65b9\u4fbf\u8bb0\u5fc6&#xff0c;\u6211\u4eec\u5c06\u547d\u540d\u7ba1\u9053\u7684\u6253\u5f00\u89c4\u5219\u6574\u7406\u6210\u8868\u683c&#xff0c;\u6838\u5fc3\u8bb0\u4f4f\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u8bfb \/ \u5199\u7aef\u76f8\u4e92\u7b49\u5f85&#xff1b;\u975e\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u8bfb\u7aef\u4e00\u5b9a\u6210\u529f&#xff0c;\u5199\u7aef\u53ef\u80fd\u5931\u8d25&#xff1a;<\/p>\n<table>\n<tr>\u6253\u5f00\u65b9\u5f0f\u65e0\u5bf9\u5e94\u8fdb\u7a0b\u6253\u5f00\u53e6\u4e00\u7aef\u6709\u5bf9\u5e94\u8fdb\u7a0b\u6253\u5f00\u53e6\u4e00\u7aef<\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#956fe7\">O_RDONLY&#xff08;\u963b\u585e\u8bfb&#xff09;<\/span><\/td>\n<td>\u963b\u585e\u7b49\u5f85<\/td>\n<td>\u7acb\u523b\u6210\u529f<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#956fe7\">O_RDONLY<\/span><\/td>\n<td>O_NONBLOCK&#xff08;\u975e\u963b\u585e\u8bfb&#xff09;<\/td>\n<td>\u7acb\u523b\u6210\u529f<\/td>\n<td>\u7acb\u523b\u6210\u529f<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#956fe7\">O_WRONLY&#xff08;\u963b\u585e\u5199&#xff09;<\/span><\/td>\n<td>\u963b\u585e\u7b49\u5f85<\/td>\n<td>\u7acb\u523b\u6210\u529f<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#956fe7\">O_WRONLY<\/span><\/td>\n<td>O_NONBLOCK&#xff08;\u975e\u963b\u585e\u5199&#xff09;<\/td>\n<td>\u5931\u8d25&#xff08;ENXIO&#xff09;<\/td>\n<td>\u7acb\u523b\u6210\u529f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6838\u5fc3\u53e3\u8bc0&#xff1a;\u5835\u8bfb\u7b49\u5199&#xff0c;\u5835\u5199\u7b49\u8bfb&#xff1b;\u975e\u5835\u8bfb\u5fc5\u6210&#xff0c;\u975e\u5835\u5199\u770b\u7aef\u3002<\/p>\n<h3 id=\"4.5%20%E6%89%93%E5%BC%80%E8%A7%84%E5%88%99%E7%9A%84%E6%9C%AC%E8%B4%A8\">4.5 \u6253\u5f00\u89c4\u5219\u7684\u672c\u8d28<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u6253\u5f00\u89c4\u5219&#xff0c;\u672c\u8d28\u662f\u4e3a\u4e86\u4fdd\u8bc1\u7ba1\u9053\u7684\u901a\u4fe1\u53cc\u65b9\u90fd\u5b58\u5728&#xff0c;\u907f\u514d\u51fa\u73b0 \u201c\u4e00\u4e2a\u8fdb\u7a0b\u5411\u7ba1\u9053\u5199\u5165\u6570\u636e&#xff0c;\u4f46\u6ca1\u6709\u8fdb\u7a0b\u8bfb\u53d6\u201d \u6216 \u201c\u4e00\u4e2a\u8fdb\u7a0b\u4ece\u7ba1\u9053\u8bfb\u53d6\u6570\u636e&#xff0c;\u4f46\u6ca1\u6709\u8fdb\u7a0b\u5199\u5165\u201d \u7684\u65e0\u6548\u64cd\u4f5c&#xff0c;\u662f\u5185\u6838\u5bf9\u7ba1\u9053\u901a\u4fe1\u7684\u57fa\u7840\u4fdd\u969c\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u800c\u975e\u963b\u585e\u6a21\u5f0f\u5219\u4e3a\u7a0b\u5e8f\u5f00\u53d1\u63d0\u4f9b\u4e86\u7075\u6d3b\u6027&#xff0c;\u8ba9\u8fdb\u7a0b\u53ef\u4ee5\u4e0d\u7b49\u5f85\u53e6\u4e00\u7aef&#xff0c;\u76f4\u63a5\u6267\u884c\u540e\u7eed\u903b\u8f91&#xff0c;\u9002\u7528\u4e8e\u9700\u8981\u8f6e\u8be2\u6216\u5904\u7406\u591a\u4efb\u52a1\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<h2 id=\"%E4%BA%94%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E8%AF%BB%E5%86%99%E8%A7%84%E5%88%99%EF%BC%9A%E5%AE%8C%E5%85%A8%E5%A4%8D%E7%94%A8%E5%8C%BF%E5%90%8D%E7%AE%A1%E9%81%93\">\u4e94\u3001\u547d\u540d\u7ba1\u9053\u7684\u8bfb\u5199\u89c4\u5219&#xff1a;\u5b8c\u5168\u590d\u7528\u533f\u540d\u7ba1\u9053<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u8bfb\u5199\u89c4\u5219\u4e0e\u533f\u540d\u7ba1\u9053\u5b8c\u5168\u4e00\u81f4&#xff0c;\u56e0\u4e3a\u4e8c\u8005\u7684\u5e95\u5c42\u90fd\u662f\u5185\u6838\u7ef4\u62a4\u7684\u5b57\u8282\u6d41\u7f13\u51b2\u533a&#xff0c;\u64cd\u4f5c\u8bed\u4e49\u5b8c\u5168\u76f8\u540c\u3002\u8fd9\u91cc\u6211\u4eec\u5bf9\u6838\u5fc3\u8bfb\u5199\u89c4\u5219\u8fdb\u884c\u91cd\u70b9\u56de\u987e&#xff0c;\u7ed3\u5408\u547d\u540d\u7ba1\u9053\u7684\u573a\u666f\u505a\u7b80\u5355\u8bf4\u660e&#xff0c;\u8ba9\u4f60\u65e0\u7f1d\u590d\u7528\u77e5\u8bc6\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u8bfb\u5199\u89c4\u5219\u540c\u6837\u4e0e\u662f\u5426\u8bbe\u7f6e\u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_NONBLOCK&#xff09;\u5bc6\u5207\u76f8\u5173&#xff0c;\u540c\u65f6\u6d89\u53ca\u539f\u5b50\u5199\u5165\u3001SIGPIPE \u4fe1\u53f7\u7b49\u5173\u952e\u7279\u6027&#xff0c;\u662f\u5f00\u53d1\u4e2d\u5fc5\u987b\u9075\u5b88\u7684\u89c4\u5219&#xff0c;\u4e5f\u662f\u9762\u8bd5\u9ad8\u9891\u8003\u70b9\u3002<\/p>\n<h3 id=\"5.1%20%E6%97%A0%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%AF%BB%E6%97%B6%E7%9A%84%E8%AF%BB%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99\">5.1 \u65e0\u6570\u636e\u53ef\u8bfb\u65f6\u7684\u8bfb\u64cd\u4f5c\u89c4\u5219<\/h3>\n<ul>\n<li>\u963b\u585e\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">read()<\/span><\/span>\u8c03\u7528\u4f1a\u963b\u585e&#xff0c;\u76f4\u5230\u6709\u8fdb\u7a0b\u5411\u7ba1\u9053\u5199\u5165\u6570\u636e&#xff0c;\u624d\u4f1a\u88ab\u5524\u9192\u5e76\u8bfb\u53d6\u6570\u636e&#xff1b;<\/li>\n<li>\u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_NONBLOCK&#xff09;&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">read()<\/span><\/span>\u8c03\u7528\u7acb\u523b\u8fd4\u56de &#8211; 1&#xff0c;<span style=\"color:#956fe7\">errno<\/span>\u8bbe\u7f6e\u4e3a<span style=\"color:#956fe7\">EAGAIN<\/span>&#xff08;\u8868\u793a\u8d44\u6e90\u6682\u65f6\u4e0d\u53ef\u7528&#xff0c;\u53ef\u91cd\u8bd5&#xff09;\u3002<\/li>\n<\/ul>\n<h3 id=\"5.2%20%E7%AE%A1%E9%81%93%E7%BC%93%E5%86%B2%E5%8C%BA%E5%86%99%E6%BB%A1%E6%97%B6%E7%9A%84%E5%86%99%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99\">5.2 \u7ba1\u9053\u7f13\u51b2\u533a\u5199\u6ee1\u65f6\u7684\u5199\u64cd\u4f5c\u89c4\u5219<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Linux \u5185\u6838\u4e2d\u7ba1\u9053\u7f13\u51b2\u533a\u7684\u9ed8\u8ba4\u5927\u5c0f\u4e3a4096 \u5b57\u8282&#xff08;1 \u9875&#xff09;&#xff0c;\u53ef\u4ee5\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">ulimit -p<\/span><\/span>\u547d\u4ee4\u67e5\u770b\u3002\u5f53\u7ba1\u9053\u7f13\u51b2\u533a\u88ab\u5199\u6ee1\u65f6&#xff1a;<\/p>\n<ul>\n<li>\u963b\u585e\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">write()<\/span><\/span>\u8c03\u7528\u4f1a\u963b\u585e&#xff0c;\u76f4\u5230\u6709\u8fdb\u7a0b\u4ece\u7ba1\u9053\u8bfb\u53d6\u6570\u636e&#xff0c;\u91ca\u653e\u7f13\u51b2\u533a\u7a7a\u95f4&#xff0c;\u624d\u4f1a\u88ab\u5524\u9192\u5e76\u7ee7\u7eed\u5199\u5165&#xff1b;<\/li>\n<li>\u975e\u963b\u585e\u6a21\u5f0f&#xff08;O_NONBLOCK&#xff09;&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">write()<\/span><\/span>\u8c03\u7528\u7acb\u523b\u8fd4\u56de &#8211; 1&#xff0c;<span style=\"color:#956fe7\">errno<\/span>\u8bbe\u7f6e\u4e3a<span style=\"color:#956fe7\">EAGAIN<\/span>\u3002<\/li>\n<\/ul>\n<h3 id=\"5.3%20%E6%89%80%E6%9C%89%E5%86%99%E7%AB%AF%E5%85%B3%E9%97%AD%E5%90%8E%E7%9A%84%E8%AF%BB%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99\">5.3 \u6240\u6709\u5199\u7aef\u5173\u95ed\u540e\u7684\u8bfb\u64cd\u4f5c\u89c4\u5219<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u6240\u6709\u6301\u6709\u7ba1\u9053\u5199\u7aef\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u8fdb\u7a0b\u90fd\u5173\u95ed\u4e86\u5199\u7aef&#xff0c;\u6b64\u65f6\u7ba1\u9053\u4e2d\u5269\u4f59\u7684\u6570\u636e\u53ef\u4ee5\u6b63\u5e38\u8bfb\u53d6&#xff1b;\u5f53\u6570\u636e\u8bfb\u53d6\u5b8c\u6bd5\u540e&#xff0c;\u518d\u6b21\u8c03\u7528<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">read()<\/span><\/span>\u4f1a\u8fd4\u56de 0&#xff0c;\u4e0e\u8bfb\u53d6\u666e\u901a\u6587\u4ef6\u5230\u672b\u5c3e\u7684\u884c\u4e3a\u4e00\u81f4&#xff0c;\u8868\u793a \u201c\u7ba1\u9053\u5df2\u65e0\u6570\u636e&#xff0c;\u4e14\u4e0d\u4f1a\u518d\u6709\u65b0\u6570\u636e\u5199\u5165\u201d\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u662f\u547d\u540d\u7ba1\u9053\u901a\u4fe1\u4e2d&#xff0c;\u8bfb\u7aef\u5224\u65ad\u5199\u7aef\u9000\u51fa\u7684\u6838\u5fc3\u65b9\u5f0f&#xff0c;\u4e5f\u662f\u5b9e\u73b0\u901a\u4fe1\u7ed3\u675f\u7684\u5173\u952e\u3002<\/p>\n<h3 id=\"5.4%20%E6%89%80%E6%9C%89%E8%AF%BB%E7%AB%AF%E5%85%B3%E9%97%AD%E5%90%8E%E7%9A%84%E5%86%99%E6%93%8D%E4%BD%9C%E8%A7%84%E5%88%99\">5.4 \u6240\u6709\u8bfb\u7aef\u5173\u95ed\u540e\u7684\u5199\u64cd\u4f5c\u89c4\u5219<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u6240\u6709\u6301\u6709\u7ba1\u9053\u8bfb\u7aef\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u8fdb\u7a0b\u90fd\u5173\u95ed\u4e86\u8bfb\u7aef&#xff0c;\u6b64\u65f6\u8fdb\u7a0b\u5411\u7ba1\u9053\u5199\u7aef\u5199\u5165\u6570\u636e\u65f6&#xff0c;\u5185\u6838\u4f1a\u5411\u8be5\u8fdb\u7a0b\u53d1\u9001SIGPIPE \u4fe1\u53f7&#xff0c;\u8be5\u4fe1\u53f7\u7684\u9ed8\u8ba4\u5904\u7406\u65b9\u5f0f\u662f\u7ec8\u6b62\u8fdb\u7a0b\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684 \u201c\u5751\u201d&#xff0c;\u5728\u547d\u540d\u7ba1\u9053\u5f00\u53d1\u4e2d&#xff0c;\u5982\u679c\u672a\u5904\u7406 SIGPIPE \u4fe1\u53f7&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u8fdb\u7a0b\u610f\u5916\u9000\u51fa\u3002\u56e0\u6b64&#xff0c;\u5b9e\u9645\u5f00\u53d1\u4e2d\u9700\u8981\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">signal()<\/span><\/span>\u6216<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">sigaction()<\/span><\/span>\u51fd\u6570\u6355\u83b7\u5e76\u5904\u7406 <span style=\"color:#956fe7\">SIGPIPE <\/span>\u4fe1\u53f7&#xff08;\u5982\u5ffd\u7565\u8be5\u4fe1\u53f7&#xff09;\u3002<\/p>\n<h3 id=\"5.5%20%E7%AE%A1%E9%81%93%E5%86%99%E5%85%A5%E7%9A%84%E5%8E%9F%E5%AD%90%E6%80%A7%E8%A7%84%E5%88%99\">5.5 \u7ba1\u9053\u5199\u5165\u7684\u539f\u5b50\u6027\u89c4\u5219<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Linux \u5185\u6838\u4fdd\u8bc1\u4e86\u547d\u540d\u7ba1\u9053\u5199\u5165\u7684\u539f\u5b50\u6027&#xff0c;\u89c4\u5219\u4e0e\u533f\u540d\u7ba1\u9053\u4e00\u81f4&#xff1a;<\/p>\n<ul>\n<li>\u5f53\u8981\u5199\u5165\u7684\u6570\u636e\u91cf\u4e0d\u5927\u4e8e PIPE_BUF&#xff08;\u5185\u6838\u5b9a\u4e49\u7684\u5b8f&#xff0c;\u9ed8\u8ba4 4096 \u5b57\u8282&#xff09;\u65f6&#xff0c;\u5185\u6838\u4fdd\u8bc1\u5199\u5165\u64cd\u4f5c\u7684\u539f\u5b50\u6027 \u2014\u2014 \u6570\u636e\u4f1a\u88ab\u5b8c\u6574\u5199\u5165&#xff0c;\u4e0d\u4f1a\u88ab\u5176\u4ed6\u8fdb\u7a0b\u7684\u5199\u5165\u64cd\u4f5c\u6253\u65ad&#xff1b;<\/li>\n<li>\u5f53\u8981\u5199\u5165\u7684\u6570\u636e\u91cf\u5927\u4e8e PIPE_BUF\u65f6&#xff0c;\u5185\u6838\u4e0d\u4fdd\u8bc1\u5199\u5165\u64cd\u4f5c\u7684\u539f\u5b50\u6027 \u2014\u2014 \u6570\u636e\u53ef\u80fd\u88ab\u62c6\u5206&#xff0c;\u4e0e\u5176\u4ed6\u8fdb\u7a0b\u7684\u5199\u5165\u6570\u636e\u4ea4\u9519\u5b58\u5728\u4e8e\u7ba1\u9053\u4e2d\u3002<\/li>\n<\/ul>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0PIPE_BUF\u7684\u53d6\u503c\u53ef\u4ee5\u901a\u8fc7<span style=\"color:#956fe7\">&lt;limits.h&gt;<\/span>\u5934\u6587\u4ef6\u67e5\u770b&#xff0c;\u4e5f\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">getconf PIPE_BUF<\/span><\/span>\u83b7\u53d6&#xff0c;\u4e0d\u540c\u7cfb\u7edf\u7684\u53d6\u503c\u53ef\u80fd\u4e0d\u540c&#xff0c;\u4f46\u81f3\u5c11\u4e3a 512 \u5b57\u8282\u3002<\/p>\n<h3 id=\"5.6%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E8%AF%BB%E5%86%99%E8%A7%84%E5%88%99%E7%9A%84%E6%A0%B8%E5%BF%83%E6%B3%A8%E6%84%8F%E7%82%B9\">5.6 \u547d\u540d\u7ba1\u9053\u8bfb\u5199\u89c4\u5219\u7684\u6838\u5fc3\u6ce8\u610f\u70b9<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u8bfb\u5199\u64cd\u4f5c\u5b8c\u5168\u9075\u5faa\u6587\u4ef6\u7684\u64cd\u4f5c\u8bed\u4e49&#xff0c;\u4f46\u53c8\u6709\u7ba1\u9053\u7684\u7279\u6b8a\u5c5e\u6027&#xff0c;\u6838\u5fc3\u6ce8\u610f\u70b9&#xff1a;<\/p>\n<li>\u547d\u540d\u7ba1\u9053\u662f\u5b57\u8282\u6d41&#xff0c;\u65e0\u6570\u636e\u8fb9\u754c&#xff0c;\u8bfb\u8fdb\u7a0b\u65e0\u6cd5\u533a\u5206\u5199\u8fdb\u7a0b\u7684\u5199\u5165\u6b21\u6570&#xff1b;<\/li>\n<li>\u8bfb\u5199\u64cd\u4f5c\u7684\u8fd4\u56de\u503c\u9700\u8981\u4e25\u683c\u5224\u65ad&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">read()<\/span><\/span>\u8fd4\u56de 0 \u8868\u793a\u5199\u7aef\u5173\u95ed&#xff0c;\u8fd4\u56de &#8211; 1 \u8868\u793a\u51fa\u9519&#xff08;\u9700\u7ed3\u5408 errno \u5224\u65ad\u662f\u963b\u585e\u8fd8\u662f\u771f\u9519\u8bef&#xff09;&#xff1b;<\/li>\n<li>\u591a\u8fdb\u7a0b\u5199\u547d\u540d\u7ba1\u9053\u65f6&#xff0c;\u4e3a\u4e86\u4fdd\u8bc1\u6570\u636e\u4e0d\u6df7\u4e71&#xff0c;\u5199\u5165\u7684\u6570\u636e\u91cf\u5fc5\u987b\u4e0d\u5927\u4e8e PIPE_BUF&#xff0c;\u5229\u7528\u539f\u5b50\u5199\u5165\u7279\u6027\u4fdd\u8bc1\u6570\u636e\u5b8c\u6574\u6027&#xff1b;<\/li>\n<li>\u53cc\u5411\u901a\u4fe1\u9700\u8981\u521b\u5efa\u4e24\u4e2a\u547d\u540d\u7ba1\u9053&#xff0c;\u5206\u522b\u8d1f\u8d23\u4e24\u4e2a\u65b9\u5411\u7684\u6570\u636e\u6d41\u3002<\/li>\n<h2 id=\"%E5%85%AD%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%AE%9E%E6%88%98%E5%BC%80%E5%8F%91%EF%BC%9A%E4%BB%8E%E5%9F%BA%E7%A1%80%E6%A1%88%E4%BE%8B%E5%88%B0%20Server-Client%20%E9%80%9A%E4%BF%A1\">\u516d\u3001\u547d\u540d\u7ba1\u9053\u7684\u5b9e\u6218\u5f00\u53d1&#xff1a;\u4ece\u57fa\u7840\u6848\u4f8b\u5230 Server-Client \u901a\u4fe1<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7406\u8bba\u5b66\u4e60\u540e&#xff0c;\u6700\u5173\u952e\u7684\u662f\u5b9e\u6218\u3002\u672c\u8282\u6211\u4eec\u901a\u8fc7\u4e09\u4e2a\u7ecf\u5178\u7684\u5b9e\u6218\u6848\u4f8b&#xff0c;\u4ece\u7b80\u5355\u5230\u590d\u6742&#xff0c;\u4e00\u6b65\u6b65\u5b9e\u73b0\u547d\u540d\u7ba1\u9053\u7684\u5f00\u53d1&#xff0c;\u5206\u522b\u662f&#xff1a;\u57fa\u7840\u8bfb\u5199\u6848\u4f8b\u3001\u6587\u4ef6\u62f7\u8d1d\u6848\u4f8b\u3001Server-Client \u901a\u4fe1\u6848\u4f8b&#xff0c;\u8986\u76d6\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u4f7f\u7528\u573a\u666f\u3002<\/p>\n<h3 id=\"6.1%20%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B%201%EF%BC%9A%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%9F%BA%E7%A1%80%E8%AF%BB%E5%86%99\">6.1 \u5b9e\u6218\u6848\u4f8b 1&#xff1a;\u547d\u540d\u7ba1\u9053\u57fa\u7840\u8bfb\u5199<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u9700\u6c42&#xff1a;\u521b\u5efa\u4e24\u4e2a\u72ec\u7acb\u7684\u7a0b\u5e8f&#xff0c;fifo_write.c&#xff08;\u5199\u7aef&#xff09;\u548cfifo_read.c&#xff08;\u8bfb\u7aef&#xff09;&#xff0c;\u5b9e\u73b0\u5199\u7aef\u5411\u547d\u540d\u7ba1\u9053\u5199\u5165\u5b57\u7b26\u4e32&#xff0c;\u8bfb\u7aef\u4ece\u547d\u540d\u7ba1\u9053\u8bfb\u53d6\u5e76\u6253\u5370&#xff0c;\u9a8c\u8bc1\u547d\u540d\u7ba1\u9053\u7684\u57fa\u672c\u901a\u4fe1\u529f\u80fd\u3002<\/p>\n<h4 id=\"6.1.1%20%E5%86%99%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_write.c\">6.1.1 \u5199\u7aef\u7a0b\u5e8f&#xff1a;fifo_write.c<\/h4>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<\/p>\n<p>\/\/ \u9519\u8bef\u5904\u7406\u5b8f<br \/>\n#define ERR_EXIT(m) \\\\<br \/>\ndo{\\\\<br \/>\n    perror(m);\\\\<br \/>\n    exit(EXIT_FAILURE);\\\\<br \/>\n}while(0)<\/p>\n<p>\/\/ \u547d\u540d\u7ba1\u9053\u6587\u4ef6\u540d<br \/>\n#define FIFO_NAME &#034;.\/myfifo&#034;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/ 1. \u521b\u5efa\u547d\u540d\u7ba1\u9053&#xff08;\u5982\u679c\u5df2\u5b58\u5728&#xff0c;\u4f1a\u62a5\u9519&#xff0c;\u8fd9\u91cc\u5148\u5224\u65ad&#xff0c;\u4e0d\u5b58\u5728\u5219\u521b\u5efa&#xff09;<br \/>\n    umask(0);<br \/>\n    if (mkfifo(FIFO_NAME, 0644) &lt; 0)<br \/>\n    {<br \/>\n        \/\/ \u9519\u8bef\u7801EEXIST\u8868\u793a\u6587\u4ef6\u5df2\u5b58\u5728&#xff0c;\u65e0\u9700\u5904\u7406<br \/>\n        if (errno !&#061; EEXIST)<br \/>\n            ERR_EXIT(&#034;mkfifo error&#034;);<br \/>\n    }<\/p>\n<p>    \/\/ 2. \u4ee5\u963b\u585e\u5199\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff08;\u9ed8\u8ba4O_WRONLY&#xff0c;\u4f1a\u963b\u585e\u7b49\u5f85\u8bfb\u7aef\u6253\u5f00&#xff09;<br \/>\n    int wfd &#061; open(FIFO_NAME, O_WRONLY);<br \/>\n    if (wfd &lt; 0)<br \/>\n        ERR_EXIT(&#034;open write error&#034;);<br \/>\n    printf(&#034;\u5199\u7aef\u6210\u529f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1a;%d\\\\n&#034;, wfd);<\/p>\n<p>    \/\/ 3. \u5411\u7ba1\u9053\u5199\u5165\u6570\u636e<br \/>\n    char buf[1024] &#061; {0};<br \/>\n    while (1)<br \/>\n    {<br \/>\n        \/\/ \u4ece\u952e\u76d8\u8bfb\u53d6\u8f93\u5165<br \/>\n        printf(&#034;\u8bf7\u8f93\u5165\u8981\u53d1\u9001\u7684\u5185\u5bb9&#xff1a;&#034;);<br \/>\n        fflush(stdout);<br \/>\n        ssize_t s &#061; read(0, buf, sizeof(buf)-1);<br \/>\n        if (s &gt; 0)<br \/>\n        {<br \/>\n            buf[s-1] &#061; 0; \/\/ \u53bb\u6389\u6362\u884c\u7b26<br \/>\n            \/\/ \u5411\u7ba1\u9053\u5199\u5165\u6570\u636e<br \/>\n            write(wfd, buf, strlen(buf));<br \/>\n            \/\/ \u8f93\u5165quit&#xff0c;\u9000\u51fa\u7a0b\u5e8f<br \/>\n            if (strcmp(buf, &#034;quit&#034;) &#061;&#061; 0)<br \/>\n                break;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ 4. \u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26<br \/>\n    close(wfd);<br \/>\n    printf(&#034;\u5199\u7aef\u5173\u95ed\u547d\u540d\u7ba1\u9053\\\\n&#034;);<br \/>\n    return 0;<br \/>\n}<\/p>\n<h4 id=\"6.1.2%20%E8%AF%BB%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_read.c\">6.1.2 \u8bfb\u7aef\u7a0b\u5e8f&#xff1a;fifo_read.c<\/h4>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;errno.h&gt;<\/p>\n<p>\/\/ \u9519\u8bef\u5904\u7406\u5b8f<br \/>\n#define ERR_EXIT(m) \\\\<br \/>\ndo{\\\\<br \/>\n    perror(m);\\\\<br \/>\n    exit(EXIT_FAILURE);\\\\<br \/>\n}while(0)<\/p>\n<p>\/\/ \u547d\u540d\u7ba1\u9053\u6587\u4ef6\u540d&#xff0c;\u4e0e\u5199\u7aef\u4fdd\u6301\u4e00\u81f4<br \/>\n#define FIFO_NAME &#034;.\/myfifo&#034;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/ 1. \u4ee5\u963b\u585e\u8bfb\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff08;\u9ed8\u8ba4O_RDONLY&#xff0c;\u4f1a\u963b\u585e\u7b49\u5f85\u5199\u7aef\u6253\u5f00&#xff09;<br \/>\n    int rfd &#061; open(FIFO_NAME, O_RDONLY);<br \/>\n    if (rfd &lt; 0)<br \/>\n        ERR_EXIT(&#034;open read error&#034;);<br \/>\n    printf(&#034;\u8bfb\u7aef\u6210\u529f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1a;%d\\\\n&#034;, rfd);<\/p>\n<p>    \/\/ 2. \u4ece\u7ba1\u9053\u8bfb\u53d6\u6570\u636e<br \/>\n    char buf[1024] &#061; {0};<br \/>\n    while (1)<br \/>\n    {<br \/>\n        ssize_t s &#061; read(rfd, buf, sizeof(buf)-1);<br \/>\n        if (s &gt; 0)<br \/>\n        {<br \/>\n            buf[s] &#061; 0;<br \/>\n            printf(&#034;\u8bfb\u7aef\u8bfb\u53d6\u5230\u6570\u636e&#xff1a;%s\\\\n&#034;, buf);<br \/>\n            \/\/ \u8bfb\u53d6\u5230quit&#xff0c;\u9000\u51fa\u7a0b\u5e8f<br \/>\n            if (strcmp(buf, &#034;quit&#034;) &#061;&#061; 0)<br \/>\n                break;<br \/>\n        }<br \/>\n        else if (s &#061;&#061; 0)<br \/>\n        {<br \/>\n            \/\/ s&#061;&#061;0\u8868\u793a\u6240\u6709\u5199\u7aef\u5173\u95ed<br \/>\n            printf(&#034;\u6240\u6709\u5199\u7aef\u5df2\u5173\u95ed&#xff0c;\u8bfb\u7aef\u9000\u51fa\\\\n&#034;);<br \/>\n            break;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            ERR_EXIT(&#034;read error&#034;);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ 3. \u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26<br \/>\n    close(rfd);<br \/>\n    \/\/ \u5220\u9664\u547d\u540d\u7ba1\u9053\u6587\u4ef6&#xff08;\u53ef\u9009&#xff0c;\u4e5f\u53ef\u4ee5\u624b\u52a8\u5220\u9664&#xff09;<br \/>\n    unlink(FIFO_NAME);<br \/>\n    printf(&#034;\u8bfb\u7aef\u5173\u95ed\u5e76\u5220\u9664\u547d\u540d\u7ba1\u9053\\\\n&#034;);<br \/>\n    return 0;<br \/>\n}<\/p>\n<h4 id=\"6.1.3%20%E7%BC%96%E8%AF%91%E4%B8%8E%E8%BF%90%E8%A1%8C\">6.1.3 \u7f16\u8bd1\u4e0e\u8fd0\u884c<\/h4>\n<li>\u7f16\u8bd1&#xff1a;\u5728\u7ec8\u7aef\u4e2d\u5206\u522b\u7f16\u8bd1\u4e24\u4e2a\u7a0b\u5e8f&#xff1a; gcc fifo_write.c -o fifo_write<br \/>\ngcc fifo_read.c -o fifo_read\n <\/li>\n<li>\u8fd0\u884c&#xff1a;\u6253\u5f00\u4e24\u4e2a\u7ec8\u7aef&#xff0c;\u5206\u522b\u8fd0\u884c\u8bfb\u7aef\u548c\u5199\u7aef&#xff08;\u987a\u5e8f\u4efb\u610f&#xff09;&#xff1a;\n<ul>\n<li>\u7ec8\u7aef 1&#xff1a;.\/fifo_read<\/li>\n<li>\u7ec8\u7aef 2&#xff1a;.\/fifo_write<\/li>\n<\/ul>\n<\/li>\n<li>\u6d4b\u8bd5&#xff1a;\u5728\u5199\u7aef\u7ec8\u7aef\u8f93\u5165\u4efb\u610f\u5b57\u7b26\u4e32&#xff0c;\u8bfb\u7aef\u7ec8\u7aef\u4f1a\u5b9e\u65f6\u6253\u5370&#xff1b;\u8f93\u5165quit&#xff0c;\u53cc\u65b9\u7a0b\u5e8f\u9000\u51fa\u3002<\/li>\n<h4 id=\"6.1.4%20%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%E5%88%86%E6%9E%90\">6.1.4 \u8fd0\u884c\u7ed3\u679c\u5206\u6790<\/h4>\n<ul>\n<li>\u65e0\u8bba\u5148\u8fd0\u884c\u8bfb\u7aef\u8fd8\u662f\u5199\u7aef&#xff0c;\u963b\u585e\u6a21\u5f0f\u4e0b\u90fd\u4f1a\u76f8\u4e92\u7b49\u5f85&#xff0c;\u76f4\u5230\u53e6\u4e00\u7aef\u6253\u5f00&#xff0c;\u624d\u4f1a\u6253\u5370 \u201c\u6210\u529f\u6253\u5f00\u547d\u540d\u7ba1\u9053\u201d&#xff1b;<\/li>\n<li>\u5199\u7aef\u8f93\u5165\u7684\u5185\u5bb9\u4f1a\u901a\u8fc7\u547d\u540d\u7ba1\u9053\u4f20\u8f93\u5230\u8bfb\u7aef&#xff0c;\u5b9e\u73b0\u65e0\u4eb2\u7f18\u8fdb\u7a0b\u95f4\u7684\u901a\u4fe1&#xff1b;<\/li>\n<li>\u5199\u7aef\u8f93\u5165quit\u540e&#xff0c;\u4f1a\u5411\u7ba1\u9053\u5199\u5165quit&#xff0c;\u8bfb\u7aef\u8bfb\u53d6\u5230\u540e\u9000\u51fa&#xff0c;\u540c\u65f6\u5220\u9664 FIFO \u6587\u4ef6&#xff1b;<\/li>\n<li>\u5982\u679c\u76f4\u63a5\u5173\u95ed\u5199\u7aef\u7ec8\u7aef&#xff0c;\u8bfb\u7aef\u4f1a\u68c0\u6d4b\u5230s&#061;&#061;0&#xff08;\u5199\u7aef\u5173\u95ed&#xff09;&#xff0c;\u5e76\u9000\u51fa\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<h3 id=\"6.2%20%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B%202%EF%BC%9A%E5%9F%BA%E4%BA%8E%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%AE%9E%E7%8E%B0%E6%96%87%E4%BB%B6%E6%8B%B7%E8%B4%9D\">6.2 \u5b9e\u6218\u6848\u4f8b 2&#xff1a;\u57fa\u4e8e\u547d\u540d\u7ba1\u9053\u5b9e\u73b0\u6587\u4ef6\u62f7\u8d1d<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u9700\u6c42&#xff1a;\u521b\u5efa\u4e24\u4e2a\u7a0b\u5e8f&#xff0c;fifo_copy_send.c&#xff08;\u53d1\u9001\u7aef&#xff09;\u548cfifo_copy_recv.c&#xff08;\u63a5\u6536\u7aef&#xff09;&#xff0c;\u5b9e\u73b0\u53d1\u9001\u7aef\u8bfb\u53d6\u672c\u5730\u6587\u4ef6&#xff0c;\u901a\u8fc7\u547d\u540d\u7ba1\u9053\u53d1\u9001\u7ed9\u63a5\u6536\u7aef&#xff0c;\u63a5\u6536\u7aef\u5c06\u6570\u636e\u5199\u5165\u65b0\u6587\u4ef6&#xff0c;\u5b8c\u6210\u6587\u4ef6\u62f7\u8d1d&#xff0c;\u9a8c\u8bc1\u547d\u540d\u7ba1\u9053\u7684\u5927\u6570\u636e\u4f20\u8f93\u80fd\u529b\u3002<\/p>\n<h4 id=\"6.2.1%20%E5%8F%91%E9%80%81%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_copy_send.c\">6.2.1 \u53d1\u9001\u7aef\u7a0b\u5e8f&#xff1a;fifo_copy_send.c<\/h4>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;errno.h&gt;<\/p>\n<p>#define ERR_EXIT(m) \\\\<br \/>\ndo{\\\\<br \/>\n    perror(m);\\\\<br \/>\n    exit(EXIT_FAILURE);\\\\<br \/>\n}while(0)<\/p>\n<p>#define FIFO_NAME &#034;.\/copy_fifo&#034;<br \/>\n#define SRC_FILE &#034;.\/src.txt&#034; \/\/ \u8981\u62f7\u8d1d\u7684\u6e90\u6587\u4ef6<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/ 1. \u521b\u5efa\u547d\u540d\u7ba1\u9053<br \/>\n    umask(0);<br \/>\n    if (mkfifo(FIFO_NAME, 0644) &lt; 0)<br \/>\n    {<br \/>\n        if (errno !&#061; EEXIST)<br \/>\n            ERR_EXIT(&#034;mkfifo error&#034;);<br \/>\n    }<\/p>\n<p>    \/\/ 2. \u6253\u5f00\u6e90\u6587\u4ef6\u548c\u547d\u540d\u7ba1\u9053<br \/>\n    int src_fd &#061; open(SRC_FILE, O_RDONLY);<br \/>\n    if (src_fd &lt; 0)<br \/>\n        ERR_EXIT(&#034;open src file error&#034;);<br \/>\n    int wfd &#061; open(FIFO_NAME, O_WRONLY);<br \/>\n    if (wfd &lt; 0)<br \/>\n        ERR_EXIT(&#034;open fifo write error&#034;);<br \/>\n    printf(&#034;\u53d1\u9001\u7aef\u51c6\u5907\u5c31\u7eea&#xff0c;\u5f00\u59cb\u62f7\u8d1d\u6587\u4ef6&#8230;\\\\n&#034;);<\/p>\n<p>    \/\/ 3. \u8bfb\u53d6\u6e90\u6587\u4ef6&#xff0c;\u5199\u5165\u547d\u540d\u7ba1\u9053<br \/>\n    char buf[1024] &#061; {0};<br \/>\n    ssize_t n &#061; 0;<br \/>\n    while ((n &#061; read(src_fd, buf, sizeof(buf))) &gt; 0)<br \/>\n    {<br \/>\n        write(wfd, buf, n);<br \/>\n    }<\/p>\n<p>    \/\/ 4. \u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26<br \/>\n    close(src_fd);<br \/>\n    close(wfd);<br \/>\n    unlink(FIFO_NAME); \/\/ \u53ef\u9009\u5220\u9664<br \/>\n    printf(&#034;\u6587\u4ef6\u62f7\u8d1d\u5b8c\u6210&#xff0c;\u53d1\u9001\u7aef\u9000\u51fa\\\\n&#034;);<br \/>\n    return 0;<br \/>\n}<\/p>\n<h4 id=\"6.2.2%20%E6%8E%A5%E6%94%B6%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9Afifo_copy_recv.c\">6.2.2 \u63a5\u6536\u7aef\u7a0b\u5e8f&#xff1a;fifo_copy_recv.c<\/h4>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<\/p>\n<p>#define ERR_EXIT(m) \\\\<br \/>\ndo{\\\\<br \/>\n    perror(m);\\\\<br \/>\n    exit(EXIT_FAILURE);\\\\<br \/>\n}while(0)<\/p>\n<p>#define FIFO_NAME &#034;.\/copy_fifo&#034;<br \/>\n#define DST_FILE &#034;.\/dst.txt&#034; \/\/ \u62f7\u8d1d\u540e\u7684\u76ee\u6807\u6587\u4ef6<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/ 1. \u6253\u5f00\u547d\u540d\u7ba1\u9053\u548c\u76ee\u6807\u6587\u4ef6<br \/>\n    int rfd &#061; open(FIFO_NAME, O_RDONLY);<br \/>\n    if (rfd &lt; 0)<br \/>\n        ERR_EXIT(&#034;open fifo read error&#034;);<br \/>\n    \/\/ \u521b\u5efa\u76ee\u6807\u6587\u4ef6&#xff0c;\u6743\u96500644&#xff0c;\u5b58\u5728\u5219\u622a\u65ad<br \/>\n    int dst_fd &#061; open(DST_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0644);<br \/>\n    if (dst_fd &lt; 0)<br \/>\n        ERR_EXIT(&#034;open dst file error&#034;);<br \/>\n    printf(&#034;\u63a5\u6536\u7aef\u51c6\u5907\u5c31\u7eea&#xff0c;\u5f00\u59cb\u63a5\u6536\u6570\u636e&#8230;\\\\n&#034;);<\/p>\n<p>    \/\/ 2. \u4ece\u547d\u540d\u7ba1\u9053\u8bfb\u53d6\u6570\u636e&#xff0c;\u5199\u5165\u76ee\u6807\u6587\u4ef6<br \/>\n    char buf[1024] &#061; {0};<br \/>\n    ssize_t n &#061; 0;<br \/>\n    while ((n &#061; read(rfd, buf, sizeof(buf))) &gt; 0)<br \/>\n    {<br \/>\n        write(dst_fd, buf, n);<br \/>\n    }<\/p>\n<p>    \/\/ 3. \u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26<br \/>\n    close(rfd);<br \/>\n    close(dst_fd);<br \/>\n    printf(&#034;\u6587\u4ef6\u63a5\u6536\u5b8c\u6210&#xff0c;\u76ee\u6807\u6587\u4ef6&#xff1a;%s\\\\n&#034;, DST_FILE);<br \/>\n    return 0;<br \/>\n}<\/p>\n<h4 id=\"6.2.3%20%E6%B5%8B%E8%AF%95%E6%AD%A5%E9%AA%A4\">6.2.3 \u6d4b\u8bd5\u6b65\u9aa4<\/h4>\n<li>\u521b\u5efa\u6e90\u6587\u4ef6src.txt&#xff0c;\u5199\u5165\u4efb\u610f\u5185\u5bb9&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">echo &#034;hello world, this is fifo copy test&#034; &gt; src.txt<\/span><\/span>&#xff1b;<\/li>\n<li>\u7f16\u8bd1\u4e24\u4e2a\u7a0b\u5e8f&#xff1a;<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">gcc fifo_copy_send.c -o send &amp;&amp; gcc fifo_copy_recv.c -o recv<\/span><\/span>&#xff1b;<\/li>\n<li>\u6253\u5f00\u4e24\u4e2a\u7ec8\u7aef&#xff0c;\u5206\u522b\u8fd0\u884c.\/recv\u548c.\/send&#xff1b;<\/li>\n<li>\u8fd0\u884c\u5b8c\u6210\u540e&#xff0c;\u67e5\u770b\u76ee\u6807\u6587\u4ef6dst.txt&#xff1a;cat dst.txt&#xff0c;\u5185\u5bb9\u4e0esrc.txt\u5b8c\u5168\u4e00\u81f4&#xff0c;\u8bf4\u660e\u6587\u4ef6\u62f7\u8d1d\u6210\u529f\u3002<\/li>\n<h4 id=\"6.2.4%20%E6%A1%88%E4%BE%8B%E6%A0%B8%E5%BF%83%E4%BA%AE%E7%82%B9\">6.2.4 \u6848\u4f8b\u6838\u5fc3\u4eae\u70b9<\/h4>\n<ul>\n<li>\u5229\u7528\u547d\u540d\u7ba1\u9053\u7684\u5b57\u8282\u6d41\u7279\u6027&#xff0c;\u5b9e\u73b0\u4e86\u4efb\u610f\u5927\u5c0f\u6587\u4ef6\u7684\u62f7\u8d1d&#xff08;\u53ea\u8981\u5185\u5b58\u8db3\u591f&#xff09;&#xff1b;<\/li>\n<li>\u8bfb\u5199\u7f13\u51b2\u533a\u8bbe\u7f6e\u4e3a 1024 \u5b57\u8282&#xff0c;\u5c0f\u4e8e <span style=\"color:#956fe7\">PIPE_BUF<\/span>&#xff08;4096&#xff09;&#xff0c;\u4fdd\u8bc1\u4e86\u5199\u5165\u7684\u539f\u5b50\u6027&#xff1b;<\/li>\n<li>\u53d1\u9001\u7aef\u8bfb\u53d6\u6587\u4ef6\u7684\u8fd4\u56de\u503c\u76f4\u63a5\u4f5c\u4e3a\u5199\u5165\u7ba1\u9053\u7684\u957f\u5ea6&#xff0c;\u4fdd\u8bc1\u4e86\u6570\u636e\u7684\u5b8c\u6574\u6027&#xff1b;<\/li>\n<li>\u5b8c\u7f8e\u4f53\u73b0\u4e86 \u201c\u4e00\u5207\u7686\u6587\u4ef6\u201d \u7684\u601d\u60f3&#xff1a;\u6587\u4ef6\u548c\u7ba1\u9053\u7684\u64cd\u4f5c\u63a5\u53e3\u5b8c\u5168\u4e00\u81f4&#xff0c;\u4ec5\u9700\u66ff\u6362\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/li>\n<\/ul>\n<h3 id=\"6.3%20%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B%203%EF%BC%9A%E5%9F%BA%E4%BA%8E%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%AE%9E%E7%8E%B0%20Server-Client%20%E9%80%9A%E4%BF%A1\">6.3 \u5b9e\u6218\u6848\u4f8b 3&#xff1a;\u57fa\u4e8e\u547d\u540d\u7ba1\u9053\u5b9e\u73b0 Server-Client \u901a\u4fe1<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u9700\u6c42&#xff1a;\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684<span style=\"color:#956fe7\">\u670d\u52a1\u7aef&#xff08;Server&#xff09;- \u5ba2\u6237\u7aef&#xff08;Client&#xff09;<\/span>\u901a\u4fe1\u6a21\u578b&#xff0c;\u670d\u52a1\u7aef\u6301\u7eed\u76d1\u542c\u547d\u540d\u7ba1\u9053&#xff0c;\u5ba2\u6237\u7aef\u5411\u670d\u52a1\u7aef\u53d1\u9001\u6d88\u606f&#xff0c;\u670d\u52a1\u7aef\u5b9e\u65f6\u6253\u5370\u5ba2\u6237\u7aef\u53d1\u9001\u7684\u5185\u5bb9&#xff0c;\u652f\u6301\u5ba2\u6237\u7aef\u9000\u51fa\u540e\u670d\u52a1\u7aef\u7ee7\u7eed\u7b49\u5f85\u65b0\u7684\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;\u8fd9\u662f\u547d\u540d\u7ba1\u9053\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u7684\u5178\u578b\u5e94\u7528\u573a\u666f\u3002<\/p>\n<h4 id=\"6.3.1%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9AserverPipe.c\">6.3.1 \u670d\u52a1\u7aef\u7a0b\u5e8f&#xff1a;serverPipe.c<\/h4>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;errno.h&gt;<\/p>\n<p>#define ERR_EXIT(m) \\\\<br \/>\ndo{\\\\<br \/>\n    perror(m);\\\\<br \/>\n    exit(EXIT_FAILURE);\\\\<br \/>\n}while(0)<\/p>\n<p>#define FIFO_NAME &#034;.\/server_fifo&#034;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/ 1. \u521b\u5efa\u547d\u540d\u7ba1\u9053&#xff0c;\u670d\u52a1\u7aef\u4f5c\u4e3a\u7ba1\u9053\u7684\u521b\u5efa\u8005<br \/>\n    umask(0);<br \/>\n    if (mkfifo(FIFO_NAME, 0644) &lt; 0)<br \/>\n    {<br \/>\n        if (errno !&#061; EEXIST)<br \/>\n            ERR_EXIT(&#034;mkfifo error&#034;);<br \/>\n    }<br \/>\n    printf(&#034;\u670d\u52a1\u7aef\u542f\u52a8&#xff0c;\u7b49\u5f85\u5ba2\u6237\u7aef\u8fde\u63a5&#8230;\\\\n&#034;);<\/p>\n<p>    while (1)<br \/>\n    {<br \/>\n        \/\/ 2. \u4ee5\u963b\u585e\u8bfb\u65b9\u5f0f\u6253\u5f00\u7ba1\u9053&#xff0c;\u5ba2\u6237\u7aef\u9000\u51fa\u540e&#xff0c;\u91cd\u65b0\u6253\u5f00\u7b49\u5f85\u65b0\u5ba2\u6237\u7aef<br \/>\n        int rfd &#061; open(FIFO_NAME, O_RDONLY);<br \/>\n        if (rfd &lt; 0)<br \/>\n            ERR_EXIT(&#034;open read error&#034;);<\/p>\n<p>        char buf[1024] &#061; {0};<br \/>\n        while (1)<br \/>\n        {<br \/>\n            ssize_t s &#061; read(rfd, buf, sizeof(buf)-1);<br \/>\n            if (s &gt; 0)<br \/>\n            {<br \/>\n                buf[s-1] &#061; 0; \/\/ \u53bb\u6389\u6362\u884c\u7b26<br \/>\n                printf(&#034;\u5ba2\u6237\u7aef\u6d88\u606f&#xff1a;%s\\\\n&#034;, buf);<br \/>\n            }<br \/>\n            else if (s &#061;&#061; 0)<br \/>\n            {<br \/>\n                \/\/ \u5ba2\u6237\u7aef\u5173\u95ed\u5199\u7aef&#xff0c;\u670d\u52a1\u7aef\u5173\u95ed\u5f53\u524d\u8bfb\u7aef&#xff0c;\u91cd\u65b0\u7b49\u5f85<br \/>\n                printf(&#034;\u5ba2\u6237\u7aef\u65ad\u5f00\u8fde\u63a5&#xff0c;\u7b49\u5f85\u65b0\u5ba2\u6237\u7aef&#8230;\\\\n&#034;);<br \/>\n                close(rfd);<br \/>\n                break;<br \/>\n            }<br \/>\n            else<br \/>\n            {<br \/>\n                ERR_EXIT(&#034;read error&#034;);<br \/>\n                close(rfd);<br \/>\n                break;<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u5b9e\u9645\u4e0d\u4f1a\u6267\u884c\u5230\u8fd9\u91cc&#xff0c;\u670d\u52a1\u7aef\u6301\u7eed\u8fd0\u884c<br \/>\n    close(rfd);<br \/>\n    unlink(FIFO_NAME);<br \/>\n    return 0;<br \/>\n}<\/p>\n<h4 id=\"6.3.2%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E7%A8%8B%E5%BA%8F%EF%BC%9AclientPipe.c\">6.3.2 \u5ba2\u6237\u7aef\u7a0b\u5e8f&#xff1a;clientPipe.c<\/h4>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;errno.h&gt;<\/p>\n<p>#define ERR_EXIT(m) \\\\<br \/>\ndo{\\\\<br \/>\n    perror(m);\\\\<br \/>\n    exit(EXIT_FAILURE);\\\\<br \/>\n}while(0)<\/p>\n<p>#define FIFO_NAME &#034;.\/server_fifo&#034;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    \/\/ 1. \u4ee5\u963b\u585e\u5199\u65b9\u5f0f\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u8fde\u63a5\u670d\u52a1\u7aef<br \/>\n    int wfd &#061; open(FIFO_NAME, O_WRONLY);<br \/>\n    if (wfd &lt; 0)<br \/>\n        ERR_EXIT(&#034;open write error&#034;);<br \/>\n    printf(&#034;\u5ba2\u6237\u7aef\u6210\u529f\u8fde\u63a5\u670d\u52a1\u7aef&#xff0c;\u8bf7\u8f93\u5165\u6d88\u606f&#xff08;\u8f93\u5165quit\u9000\u51fa&#xff09;&#xff1a;\\\\n&#034;);<\/p>\n<p>    \/\/ 2. \u5411\u670d\u52a1\u7aef\u53d1\u9001\u6d88\u606f<br \/>\n    char buf[1024] &#061; {0};<br \/>\n    while (1)<br \/>\n    {<br \/>\n        printf(&#034;&gt; &#034;);<br \/>\n        fflush(stdout);<br \/>\n        ssize_t s &#061; read(0, buf, sizeof(buf)-1);<br \/>\n        if (s &gt; 0)<br \/>\n        {<br \/>\n            write(wfd, buf, s);<br \/>\n            if (strncmp(buf, &#034;quit&#034;, 4) &#061;&#061; 0)<br \/>\n            {<br \/>\n                printf(&#034;\u5ba2\u6237\u7aef\u9000\u51fa\\\\n&#034;);<br \/>\n                break;<br \/>\n            }<br \/>\n            memset(buf, 0, sizeof(buf));<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ 3. \u5173\u95ed\u5199\u7aef<br \/>\n    close(wfd);<br \/>\n    return 0;<br \/>\n}<\/p>\n<h4 id=\"6.3.3%20%E7%BC%96%E8%AF%91%E4%B8%8E%E8%BF%90%E8%A1%8C\">6.3.3 \u7f16\u8bd1\u4e0e\u8fd0\u884c<\/h4>\n<li>\u7f16\u5199 Makefile&#xff0c;\u65b9\u4fbf\u7f16\u8bd1&#xff1a; .PHONY:all<br \/>\nall:serverPipe clientPipe<\/p>\n<p>serverPipe:serverPipe.c<br \/>\n    gcc -o $&#064; $^<br \/>\nclientPipe:clientPipe.c<br \/>\n    gcc -o $&#064; $^<\/p>\n<p>.PHONY:clean<br \/>\nclean:<br \/>\n    rm -f serverPipe clientPipe\n <\/li>\n<li>\u7f16\u8bd1&#xff1a;make&#xff1b;<\/li>\n<li>\u8fd0\u884c\u670d\u52a1\u7aef&#xff1a;.\/serverPipe&#xff0c;\u670d\u52a1\u7aef\u542f\u52a8\u5e76\u7b49\u5f85\u5ba2\u6237\u7aef\u8fde\u63a5&#xff1b;<\/li>\n<li>\u8fd0\u884c\u5ba2\u6237\u7aef&#xff1a;\u6253\u5f00\u65b0\u7ec8\u7aef&#xff0c;.\/clientPipe&#xff0c;\u5ba2\u6237\u7aef\u6210\u529f\u8fde\u63a5\u670d\u52a1\u7aef&#xff1b;<\/li>\n<li>\u6d4b\u8bd5&#xff1a;\u5ba2\u6237\u7aef\u8f93\u5165\u4efb\u610f\u6d88\u606f&#xff0c;\u670d\u52a1\u7aef\u5b9e\u65f6\u6253\u5370&#xff1b;\u5ba2\u6237\u7aef\u8f93\u5165quit&#xff0c;\u65ad\u5f00\u8fde\u63a5&#xff0c;\u670d\u52a1\u7aef\u7ee7\u7eed\u7b49\u5f85\u65b0\u7684\u5ba2\u6237\u7aef&#xff1b;<\/li>\n<li>\u591a\u5ba2\u6237\u7aef\u6d4b\u8bd5&#xff1a;\u6253\u5f00\u591a\u4e2a\u7ec8\u7aef&#xff0c;\u8fd0\u884c\u591a\u4e2a.\/clientPipe&#xff0c;\u4f9d\u6b21\u5411\u670d\u52a1\u7aef\u53d1\u9001\u6d88\u606f&#xff0c;\u670d\u52a1\u7aef\u5747\u53ef\u6b63\u5e38\u63a5\u6536\u3002<\/li>\n<h4 id=\"6.3.4%20%E6%A1%88%E4%BE%8B%E6%A0%B8%E5%BF%83%E4%BA%AE%E7%82%B9\">6.3.4 \u6848\u4f8b\u6838\u5fc3\u4eae\u70b9<\/h4>\n<ul>\n<li>\u670d\u52a1\u7aef\u901a\u8fc7\u5916\u5c42\u6b7b\u5faa\u73af&#xff0c;\u5b9e\u73b0\u4e86\u6301\u7eed\u76d1\u542c&#xff0c;\u5ba2\u6237\u7aef\u9000\u51fa\u540e&#xff0c;\u91cd\u65b0\u6253\u5f00\u547d\u540d\u7ba1\u9053&#xff0c;\u7b49\u5f85\u65b0\u7684\u5ba2\u6237\u7aef\u8fde\u63a5&#xff1b;<\/li>\n<li>\u5229\u7528\u5199\u7aef\u5173\u95ed\u540e\u8bfb\u7aef read \u8fd4\u56de 0\u7684\u7279\u6027&#xff0c;\u670d\u52a1\u7aef\u80fd\u7cbe\u51c6\u68c0\u6d4b\u5230\u5ba2\u6237\u7aef\u7684\u65ad\u5f00\u8fde\u63a5&#xff1b;<\/li>\n<li>\u5b9e\u73b0\u4e86\u4e00\u5bf9\u591a\u7684\u901a\u4fe1\u96cf\u5f62&#xff0c;\u4e00\u4e2a\u670d\u52a1\u7aef\u53ef\u4ee5\u4e3a\u591a\u4e2a\u5ba2\u6237\u7aef\u63d0\u4f9b\u901a\u4fe1\u670d\u52a1&#xff1b;<\/li>\n<li>\u4ee3\u7801\u7b80\u6d01&#xff0c;\u6838\u5fc3\u903b\u8f91\u6e05\u6670&#xff0c;\u53ef\u76f4\u63a5\u6269\u5c55\u4e3a\u66f4\u590d\u6742\u7684\u901a\u4fe1\u6a21\u578b&#xff08;\u5982\u6dfb\u52a0\u6d88\u606f\u89e3\u6790\u3001\u6307\u4ee4\u5904\u7406\u7b49&#xff09;\u3002<\/li>\n<\/ul>\n<h2 id=\"%E4%B8%83%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E7%89%B9%E7%82%B9%E4%B8%8E%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF\">\u4e03\u3001\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u7279\u70b9\u4e0e\u4f7f\u7528\u573a\u666f<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7ed3\u5408\u524d\u9762\u7684\u539f\u7406\u548c\u5b9e\u6218&#xff0c;\u6211\u4eec\u603b\u7ed3\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u7279\u70b9&#xff0c;\u5e76\u68b3\u7406\u5176\u5178\u578b\u7684\u4f7f\u7528\u573a\u666f&#xff0c;\u5e2e\u52a9\u4f60\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u5feb\u901f\u5224\u65ad\u662f\u5426\u9002\u5408\u4f7f\u7528\u547d\u540d\u7ba1\u9053\u3002<\/p>\n<h3 id=\"7.1%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E6%A0%B8%E5%BF%83%E7%89%B9%E7%82%B9\">7.1 \u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u7279\u70b9<\/h3>\n<li>\u65e0\u4eb2\u7f18\u9650\u5236&#xff1a;\u6700\u5927\u7684\u4f18\u52bf&#xff0c;\u652f\u6301\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684\u901a\u4fe1&#xff0c;\u53ea\u8981\u8fdb\u7a0b\u80fd\u8bbf\u95ee FIFO \u6587\u4ef6&#xff08;\u6743\u9650\u8db3\u591f&#xff09;&#xff1b;<\/li>\n<li>\u57fa\u4e8e\u6587\u4ef6\u7cfb\u7edf&#xff1a;FIFO \u6587\u4ef6\u5b58\u5728\u4e8e\u6587\u4ef6\u7cfb\u7edf\u4e2d&#xff0c;\u8fdb\u7a0b\u9000\u51fa\u540e\u6587\u4ef6\u4fdd\u7559&#xff0c;\u53ef\u91cd\u590d\u4f7f\u7528&#xff08;\u9700\u624b\u52a8\u5220\u9664&#xff09;&#xff1b;<\/li>\n<li>\u64cd\u4f5c\u63a5\u53e3\u7edf\u4e00&#xff1a;\u5b8c\u5168\u4f7f\u7528open()\/read()\/write()\/close()\u7b49\u6807\u51c6\u6587\u4ef6\u64cd\u4f5c\u63a5\u53e3&#xff0c;\u5951\u5408 \u201c\u4e00\u5207\u7686\u6587\u4ef6\u201d \u601d\u60f3&#xff0c;\u5b66\u4e60\u6210\u672c\u4f4e&#xff1b;<\/li>\n<li>\u8bfb\u5199\u89c4\u5219\u4e0e\u533f\u540d\u7ba1\u9053\u4e00\u81f4&#xff1a;\u963b\u585e \/ \u975e\u963b\u585e\u3001\u539f\u5b50\u5199\u5165\u3001SIGPIPE \u4fe1\u53f7\u7b49\u89c4\u5219\u5b8c\u5168\u590d\u7528&#xff0c;\u65e0\u9700\u91cd\u65b0\u5b66\u4e60&#xff1b;<\/li>\n<li>\u534a\u53cc\u5de5\u901a\u4fe1&#xff1a;\u6570\u636e\u53ea\u80fd\u5355\u5411\u6d41\u52a8&#xff0c;\u53cc\u5411\u901a\u4fe1\u9700\u8981\u521b\u5efa\u4e24\u4e2a\u547d\u540d\u7ba1\u9053&#xff1b;<\/li>\n<li>\u5b57\u8282\u6d41\u670d\u52a1&#xff1a;\u65e0\u6570\u636e\u8fb9\u754c&#xff0c;\u8bfb\u8fdb\u7a0b\u65e0\u6cd5\u533a\u5206\u5199\u8fdb\u7a0b\u7684\u5199\u5165\u6b21\u6570&#xff0c;\u9700\u624b\u52a8\u5b9a\u4e49\u6570\u636e\u683c\u5f0f&#xff08;\u5982\u6dfb\u52a0\u5206\u9694\u7b26\u3001\u6d88\u606f\u5934&#xff09;&#xff1b;<\/li>\n<li>\u751f\u547d\u5468\u671f\u4e0e\u8fdb\u7a0b &#043; \u6587\u4ef6&#xff1a;\u5185\u6838\u7f13\u51b2\u533a\u7684\u751f\u547d\u5468\u671f\u968f\u8fdb\u7a0b&#xff08;\u6240\u6709\u8fdb\u7a0b\u5173\u95ed\u540e\u91ca\u653e&#xff09;&#xff0c;FIFO \u6587\u4ef6\u7684\u751f\u547d\u5468\u671f\u968f\u6587\u4ef6\u7cfb\u7edf&#xff08;\u9700\u624b\u52a8\u5220\u9664&#xff09;&#xff1b;<\/li>\n<li>\u5185\u6838\u81ea\u52a8\u540c\u6b65\u4e92\u65a5&#xff1a;\u540c\u4e00\u65f6\u523b\u53ea\u5141\u8bb8\u4e00\u4e2a\u8fdb\u7a0b\u5bf9\u7ba1\u9053\u8fdb\u884c\u8bfb \/ \u5199\u64cd\u4f5c&#xff0c;\u907f\u514d\u6570\u636e\u6df7\u4e71\u3002<\/li>\n<h3 id=\"7.2%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%85%B8%E5%9E%8B%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF\">7.2 \u547d\u540d\u7ba1\u9053\u7684\u5178\u578b\u4f7f\u7528\u573a\u666f<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u9002\u7528\u4e8e\u7b80\u5355\u3001\u4f4e\u5e76\u53d1\u3001\u5355\u5411 \/ \u53cc\u5411\u5b57\u8282\u6d41\u901a\u4fe1\u7684\u573a\u666f&#xff0c;\u5c24\u5176\u662f\u9700\u8981\u5728\u65e0\u4eb2\u7f18\u8fdb\u7a0b\u95f4\u4f20\u9012\u6570\u636e\u7684\u573a\u666f&#xff0c;\u5178\u578b\u5e94\u7528\u5305\u62ec&#xff1a;<\/p>\n<li>\u72ec\u7acb\u8fdb\u7a0b\u95f4\u7684\u7b80\u5355\u6570\u636e\u4f20\u8f93&#xff1a;\u5982\u4e24\u4e2a\u72ec\u7acb\u7684\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u4f20\u9012\u914d\u7f6e\u3001\u72b6\u6001\u3001\u65e5\u5fd7\u7b49\u7b80\u5355\u6570\u636e&#xff1b;<\/li>\n<li>\u670d\u52a1\u7aef &#8211; \u5ba2\u6237\u7aef\u7684\u57fa\u7840\u901a\u4fe1&#xff1a;\u5982\u7b80\u5355\u7684\u672c\u5730\u670d\u52a1\u7aef\u7a0b\u5e8f&#xff0c;\u4e3a\u5ba2\u6237\u7aef\u63d0\u4f9b\u57fa\u7840\u7684\u6d88\u606f\u54cd\u5e94\u670d\u52a1&#xff1b;<\/li>\n<li>\u672c\u5730\u7a0b\u5e8f\u7684\u8fdb\u7a0b\u95f4\u534f\u4f5c&#xff1a;\u5982\u4e00\u4e2a\u4e3b\u7a0b\u5e8f\u542f\u52a8\u591a\u4e2a\u5b50\u8fdb\u7a0b&#xff0c;\u5b50\u8fdb\u7a0b\u901a\u8fc7\u547d\u540d\u7ba1\u9053\u5411\u4e3b\u7a0b\u5e8f\u4e0a\u62a5\u8fd0\u884c\u72b6\u6001&#xff1b;<\/li>\n<li>\u6587\u4ef6 \/ \u6570\u636e\u7684\u8de8\u8fdb\u7a0b\u62f7\u8d1d&#xff1a;\u5982\u5c06\u4e00\u4e2a\u8fdb\u7a0b\u7684\u8f93\u51fa\u6570\u636e&#xff0c;\u901a\u8fc7\u547d\u540d\u7ba1\u9053\u76f4\u63a5\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u7684\u8f93\u5165&#xff0c;\u5b9e\u73b0\u6570\u636e\u7684\u65e0\u7f1d\u6d41\u8f6c&#xff1b;<\/li>\n<li>\u811a\u672c\u4e0e\u7a0b\u5e8f\u95f4\u7684\u901a\u4fe1&#xff1a;\u5982 Shell \u811a\u672c\u901a\u8fc7\u547d\u540d\u7ba1\u9053\u5411 C\/C&#043;&#043; \u7a0b\u5e8f\u4f20\u9012\u6307\u4ee4\u6216\u6570\u636e&#xff0c;\u5b9e\u73b0\u811a\u672c\u4e0e\u7f16\u8bd1\u578b\u7a0b\u5e8f\u7684\u534f\u4f5c\u3002<\/li>\n<h3 id=\"7.3%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E7%9A%84%E5%B1%80%E9%99%90%E6%80%A7\">7.3 \u547d\u540d\u7ba1\u9053\u7684\u5c40\u9650\u6027<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u5e76\u975e\u4e07\u80fd\u7684&#xff0c;\u4e5f\u5b58\u5728\u4e00\u4e9b\u5c40\u9650\u6027&#xff0c;\u5728\u9ad8\u5e76\u53d1\u3001\u9ad8\u8981\u6c42\u7684\u901a\u4fe1\u573a\u666f\u4e2d&#xff0c;\u9700\u8981\u9009\u62e9\u5176\u4ed6 IPC \u65b9\u5f0f&#xff1a;<\/p>\n<li>\u534a\u53cc\u5de5\u901a\u4fe1&#xff1a;\u53cc\u5411\u901a\u4fe1\u9700\u8981\u521b\u5efa\u4e24\u4e2a\u7ba1\u9053&#xff0c;\u589e\u52a0\u4e86\u5f00\u53d1\u590d\u6742\u5ea6&#xff1b;<\/li>\n<li>\u65e0\u6d88\u606f\u8fb9\u754c&#xff1a;\u5b57\u8282\u6d41\u6a21\u5f0f&#xff0c;\u9700\u8981\u624b\u52a8\u5904\u7406\u6570\u636e\u7684\u62c6\u5206\u548c\u89e3\u6790&#xff0c;\u5bb9\u6613\u51fa\u73b0\u7c98\u5305\u95ee\u9898&#xff1b;<\/li>\n<li>\u4e0d\u652f\u6301\u8de8\u4e3b\u673a\u901a\u4fe1&#xff1a;\u4ec5\u9002\u7528\u4e8e\u540c\u4e00\u53f0 Linux \u4e3b\u673a\u4e0a\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1&#xff0c;\u65e0\u6cd5\u5b9e\u73b0\u8de8\u4e3b\u673a\u7684\u7f51\u7edc\u901a\u4fe1&#xff1b;<\/li>\n<li>\u5e76\u53d1\u6027\u80fd\u4e00\u822c&#xff1a;\u5185\u6838\u7684\u540c\u6b65\u4e92\u65a5\u673a\u5236\u9650\u5236\u4e86\u5e76\u53d1\u8bfb\u5199\u7684\u6027\u80fd&#xff0c;\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u6548\u7387\u8f83\u4f4e&#xff1b;<\/li>\n<li>\u65e0\u81ea\u5e26\u7684\u6d88\u606f\u683c\u5f0f&#xff1a;\u9700\u8981\u5f00\u53d1\u8005\u624b\u52a8\u5b9a\u4e49\u6d88\u606f\u683c\u5f0f&#xff0c;\u5982\u6d88\u606f\u957f\u5ea6\u3001\u6d88\u606f\u7c7b\u578b\u7b49&#xff0c;\u4e0d\u5982\u6d88\u606f\u961f\u5217\u7075\u6d3b\u3002<\/li>\n<h3 id=\"7.4%20%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E4%B8%8E%E5%85%B6%E4%BB%96%20IPC%20%E6%96%B9%E5%BC%8F%E7%9A%84%E5%AF%B9%E6%AF%94\">7.4 \u547d\u540d\u7ba1\u9053\u4e0e\u5176\u4ed6 IPC \u65b9\u5f0f\u7684\u5bf9\u6bd4<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e3a\u4e86\u65b9\u4fbf\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u9009\u62e9\u5408\u9002\u7684 IPC \u65b9\u5f0f&#xff0c;\u6211\u4eec\u5c06\u547d\u540d\u7ba1\u9053\u4e0e\u5e38\u89c1\u7684 IPC \u65b9\u5f0f&#xff08;\u533f\u540d\u7ba1\u9053\u3001\u5171\u4eab\u5185\u5b58\u3001\u6d88\u606f\u961f\u5217\u3001Socket&#xff09;\u8fdb\u884c\u6838\u5fc3\u5bf9\u6bd4&#xff1a;<\/p>\n<table>\n<tr>IPC \u65b9\u5f0f\u4eb2\u7f18\u9650\u5236\u901a\u4fe1\u65b9\u5411\u6570\u636e\u683c\u5f0f\u8de8\u4e3b\u673a\u5e76\u53d1\u6027\u80fd\u6838\u5fc3\u4f18\u52bf<\/tr>\n<tbody>\n<tr>\n<td>\u533f\u540d\u7ba1\u9053<\/td>\n<td>\u6709<\/td>\n<td>\u534a\u53cc\u5de5<\/td>\n<td>\u5b57\u8282\u6d41<\/td>\n<td>\u5426<\/td>\n<td>\u4e00\u822c<\/td>\n<td>\u7b80\u5355\u3001\u8f7b\u91cf\u3001\u4eb2\u7f18\u8fdb\u7a0b\u4e13\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u547d\u540d\u7ba1\u9053<\/td>\n<td>\u65e0<\/td>\n<td>\u534a\u53cc\u5de5<\/td>\n<td>\u5b57\u8282\u6d41<\/td>\n<td>\u5426<\/td>\n<td>\u4e00\u822c<\/td>\n<td>\u65e0\u4eb2\u7f18\u9650\u5236\u3001\u63a5\u53e3\u7edf\u4e00<\/td>\n<\/tr>\n<tr>\n<td>\u5171\u4eab\u5185\u5b58<\/td>\n<td>\u65e0<\/td>\n<td>\u5168\u53cc\u5de5<\/td>\n<td>\u81ea\u5b9a\u4e49<\/td>\n<td>\u5426<\/td>\n<td>\u6781\u9ad8<\/td>\n<td>\u6700\u5feb\u7684 IPC \u65b9\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>\u6d88\u606f\u961f\u5217<\/td>\n<td>\u65e0<\/td>\n<td>\u5168\u53cc\u5de5<\/td>\n<td>\u6d88\u606f<\/td>\n<td>\u5426<\/td>\n<td>\u8f83\u597d<\/td>\n<td>\u6709\u6d88\u606f\u8fb9\u754c\u3001\u81ea\u5e26\u683c\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>Socket&#xff08;\u672c\u5730&#xff09;<\/td>\n<td>\u65e0<\/td>\n<td>\u5168\u53cc\u5de5<\/td>\n<td>\u5b57\u8282\u6d41 \/ \u6570\u636e\u5305<\/td>\n<td>\u662f<\/td>\n<td>\u8f83\u597d<\/td>\n<td>\u8de8\u4e3b\u673a\u3001\u529f\u80fd\u5f3a\u5927<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9009\u62e9\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u4eb2\u7f18\u8fdb\u7a0b\u95f4\u7b80\u5355\u901a\u4fe1&#xff1a;\u533f\u540d\u7ba1\u9053&#xff1b;<\/li>\n<li>\u65e0\u4eb2\u7f18\u8fdb\u7a0b\u95f4\u672c\u5730\u7b80\u5355\u901a\u4fe1&#xff1a;\u547d\u540d\u7ba1\u9053&#xff1b;<\/li>\n<li>\u672c\u5730\u9ad8\u901f\u5ea6\u5927\u6570\u636e\u4f20\u8f93&#xff1a;\u5171\u4eab\u5185\u5b58&#xff08;\u9700\u624b\u52a8\u5b9e\u73b0\u540c\u6b65\u4e92\u65a5&#xff09;&#xff1b;<\/li>\n<li>\u672c\u5730\u9700\u8981\u6d88\u606f\u8fb9\u754c\u7684\u901a\u4fe1&#xff1a;\u6d88\u606f\u961f\u5217&#xff1b;<\/li>\n<li>\u8de8\u4e3b\u673a\u901a\u4fe1\u6216\u590d\u6742\u7684\u672c\u5730\u901a\u4fe1&#xff1a;Socket\u3002<\/li>\n<\/ul>\n<h2 id=\"%E5%85%AB%E3%80%81%E5%91%BD%E5%90%8D%E7%AE%A1%E9%81%93%E5%BC%80%E5%8F%91%E7%9A%84%E9%81%BF%E5%9D%91%E6%8C%87%E5%8D%97\">\u516b\u3001\u547d\u540d\u7ba1\u9053\u5f00\u53d1\u7684\u907f\u5751\u6307\u5357<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u547d\u540d\u7ba1\u9053\u7684\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u65b0\u624b\u5f88\u5bb9\u6613\u8e29\u5751&#xff0c;\u5bfc\u81f4\u7a0b\u5e8f\u51fa\u73b0\u963b\u585e\u3001\u5d29\u6e83\u3001\u6570\u636e\u4e22\u5931\u7b49\u95ee\u9898\u3002\u672c\u8282\u68b3\u7406\u5f00\u53d1\u4e2d\u6700\u5e38\u89c1\u7684\u5751&#xff0c;\u5e76\u7ed9\u51fa\u5bf9\u5e94\u7684\u89e3\u51b3\u65b9\u6848&#xff0c;\u5e2e\u52a9\u4f60\u907f\u5f00\u9677\u9631&#xff0c;\u5199\u51fa\u5065\u58ee\u7684\u4ee3\u7801\u3002<\/p>\n<h3 id=\"8.1%20%E5%9D%91%201%EF%BC%9A%E6%9C%AA%E5%A4%84%E7%90%86%20SIGPIPE%20%E4%BF%A1%E5%8F%B7%EF%BC%8C%E5%AF%BC%E8%87%B4%E8%BF%9B%E7%A8%8B%E6%84%8F%E5%A4%96%E9%80%80%E5%87%BA\">8.1 \u5751 1&#xff1a;\u672a\u5904\u7406 SIGPIPE \u4fe1\u53f7&#xff0c;\u5bfc\u81f4\u8fdb\u7a0b\u610f\u5916\u9000\u51fa<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u95ee\u9898&#xff1a;\u6240\u6709\u8bfb\u7aef\u5173\u95ed\u540e&#xff0c;\u5199\u7aef\u7ee7\u7eed\u5199\u5165\u6570\u636e&#xff0c;\u5185\u6838\u4f1a\u53d1\u9001 SIGPIPE \u4fe1\u53f7&#xff0c;\u9ed8\u8ba4\u5904\u7406\u65b9\u5f0f\u662f\u7ec8\u6b62\u8fdb\u7a0b&#xff0c;\u5bfc\u81f4\u7a0b\u5e8f\u610f\u5916\u9000\u51fa\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u89e3\u51b3\u65b9\u6848&#xff1a;\u5728\u5199\u7aef\u7a0b\u5e8f\u4e2d&#xff0c;\u6355\u83b7\u5e76\u5ffd\u7565 SIGPIPE \u4fe1\u53f7&#xff1a;<\/p>\n<p>#include &lt;signal.h&gt;<br \/>\n\/\/ \u5ffd\u7565SIGPIPE\u4fe1\u53f7<br \/>\nsignal(SIGPIPE, SIG_IGN);<\/p>\n<h3 id=\"8.2%20%E5%9D%91%202%EF%BC%9A%E9%9D%9E%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%E4%B8%8B%EF%BC%8C%E9%94%99%E8%AF%AF%E5%88%A4%E6%96%AD%E4%B8%8D%E4%B8%A5%E8%B0%A8\">8.2 \u5751 2&#xff1a;\u975e\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u9519\u8bef\u5224\u65ad\u4e0d\u4e25\u8c28<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u95ee\u9898&#xff1a;\u975e\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;read()\/write()\u8fd4\u56de &#8211; 1 \u65f6&#xff0c;\u76f4\u63a5\u8ba4\u4e3a\u662f\u7a0b\u5e8f\u9519\u8bef&#xff0c;\u5b9e\u9645\u4e0a\u53ef\u80fd\u662fEAGAIN&#xff08;\u8d44\u6e90\u6682\u65f6\u4e0d\u53ef\u7528&#xff09;&#xff0c;\u5c5e\u4e8e\u6b63\u5e38\u60c5\u51b5\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u89e3\u51b3\u65b9\u6848&#xff1a;\u5224\u65ad\u8fd4\u56de\u503c\u4e3a &#8211; 1 \u65f6&#xff0c;\u7ed3\u5408errno\u8fdb\u884c\u5224\u65ad&#xff0c;\u5ffd\u7565EAGAIN&#xff1a;<\/p>\n<p>ssize_t s &#061; read(rfd, buf, sizeof(buf));<br \/>\nif (s &lt; 0)<br \/>\n{<br \/>\n    if (errno &#061;&#061; EAGAIN)<br \/>\n    {<br \/>\n        \/\/ \u975e\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u65e0\u6570\u636e&#xff0c;\u53ef\u91cd\u8bd5<br \/>\n        continue;<br \/>\n    }<br \/>\n    else<br \/>\n    {<br \/>\n        \/\/ \u771f\u6b63\u7684\u9519\u8bef&#xff0c;\u5904\u7406<br \/>\n        perror(&#034;read error&#034;);<br \/>\n        break;<br \/>\n    }<br \/>\n}<\/p>\n<h3 id=\"8.3%20%E5%9D%91%203%EF%BC%9A%E5%A4%9A%E8%BF%9B%E7%A8%8B%E5%86%99%E7%AE%A1%E9%81%93%E6%97%B6%EF%BC%8C%E6%95%B0%E6%8D%AE%E6%B7%B7%E4%B9%B1\">8.3 \u5751 3&#xff1a;\u591a\u8fdb\u7a0b\u5199\u7ba1\u9053\u65f6&#xff0c;\u6570\u636e\u6df7\u4e71<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u95ee\u9898&#xff1a;\u591a\u4e2a\u8fdb\u7a0b\u540c\u65f6\u5411\u547d\u540d\u7ba1\u9053\u5199\u5165\u6570\u636e&#xff0c;\u4e14\u5199\u5165\u7684\u6570\u636e\u91cf\u5927\u4e8e PIPE_BUF&#xff0c;\u5bfc\u81f4\u6570\u636e\u4ea4\u9519&#xff0c;\u51fa\u73b0\u6df7\u4e71\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u89e3\u51b3\u65b9\u6848&#xff1a;\u4fdd\u8bc1\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u5199\u5165\u6570\u636e\u91cf\u4e0d\u5927\u4e8e PIPE_BUF&#xff0c;\u5229\u7528\u539f\u5b50\u5199\u5165\u7279\u6027&#xff0c;\u907f\u514d\u6570\u636e\u4ea4\u9519&#xff1b;\u5982\u679c\u9700\u8981\u5199\u5165\u5927\u6570\u636e&#xff0c;\u53ef\u5c06\u6570\u636e\u62c6\u5206\u4e3a\u591a\u4e2a PIPE_BUF \u5927\u5c0f\u7684\u5757&#xff0c;\u4f9d\u6b21\u5199\u5165\u3002<\/p>\n<h3 id=\"8.4%20%E5%9D%91%204%EF%BC%9A%E5%8F%8C%E5%90%91%E9%80%9A%E4%BF%A1%E6%97%B6%EF%BC%8C%E5%8F%AA%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E7%AE%A1%E9%81%93%EF%BC%8C%E5%AF%BC%E8%87%B4%E6%AD%BB%E9%94%81\">8.4 \u5751 4&#xff1a;\u53cc\u5411\u901a\u4fe1\u65f6&#xff0c;\u53ea\u521b\u5efa\u4e00\u4e2a\u7ba1\u9053&#xff0c;\u5bfc\u81f4\u6b7b\u9501<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u95ee\u9898&#xff1a;\u5b9e\u73b0\u53cc\u5411\u901a\u4fe1\u65f6&#xff0c;\u53ea\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u7ba1\u9053&#xff0c;\u4e24\u4e2a\u8fdb\u7a0b\u540c\u65f6\u4ee5\u8bfb &#043; \u5199\u65b9\u5f0f\u6253\u5f00&#xff0c;\u5bfc\u81f4\u53cc\u65b9\u76f8\u4e92\u963b\u585e&#xff0c;\u51fa\u73b0\u6b7b\u9501\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u89e3\u51b3\u65b9\u6848&#xff1a;\u53cc\u5411\u901a\u4fe1\u5fc5\u987b\u521b\u5efa\u4e24\u4e2a\u547d\u540d\u7ba1\u9053&#xff0c;\u5206\u522b\u8d1f\u8d23 A\u2192B \u548c B\u2192A \u7684\u6570\u636e\u6d41&#xff0c;\u6bcf\u4e2a\u8fdb\u7a0b\u5bf9\u4e00\u4e2a\u7ba1\u9053\u8bfb&#xff0c;\u5bf9\u53e6\u4e00\u4e2a\u7ba1\u9053\u5199\u3002<\/p>\n<h3 id=\"8.5%20%E5%9D%91%205%EF%BC%9AFIFO%20%E6%96%87%E4%BB%B6%E6%9C%AA%E5%88%A0%E9%99%A4%EF%BC%8C%E5%AF%BC%E8%87%B4%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%90%AF%E6%97%B6%20mkfifo%20%E6%8A%A5%E9%94%99\">8.5 \u5751 5&#xff1a;FIFO \u6587\u4ef6\u672a\u5220\u9664&#xff0c;\u5bfc\u81f4\u7a0b\u5e8f\u91cd\u542f\u65f6 mkfifo \u62a5\u9519<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u95ee\u9898&#xff1a;\u7a0b\u5e8f\u9000\u51fa\u540e&#xff0c;\u672a\u5220\u9664 FIFO \u6587\u4ef6&#xff0c;\u518d\u6b21\u542f\u52a8\u7a0b\u5e8f\u65f6&#xff0c;mkfifo()\u4f1a\u56e0\u6587\u4ef6\u5df2\u5b58\u5728\u800c\u62a5\u9519&#xff08;errno&#061;EEXIST&#xff09;\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<li>\u5728<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">mkfifo()<\/span><\/span>\u540e&#xff0c;\u5224\u65ad errno \u662f\u5426\u4e3a EEXIST&#xff0c;\u82e5\u662f\u5219\u5ffd\u7565\u9519\u8bef&#xff1b;<\/li>\n<li>\u8bfb\u7aef \/ \u670d\u52a1\u7aef\u9000\u51fa\u65f6&#xff0c;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">unlink()<\/span><\/span>\u51fd\u6570\u5220\u9664 FIFO \u6587\u4ef6&#xff1b;<\/li>\n<li>\u7a0b\u5e8f\u542f\u52a8\u65f6&#xff0c;\u5148\u68c0\u67e5 FIFO \u6587\u4ef6\u662f\u5426\u5b58\u5728&#xff0c;\u82e5\u5b58\u5728\u5219\u5148\u5220\u9664\u3002<\/li>\n<h3 id=\"8.6%20%E5%9D%91%206%EF%BC%9A%E9%98%BB%E5%A1%9E%E6%A8%A1%E5%BC%8F%E4%B8%8B%EF%BC%8C%E8%BF%9B%E7%A8%8B%E5%8D%A1%E6%AD%BB%EF%BC%8C%E6%97%A0%E6%B3%95%E9%80%80%E5%87%BA\">8.6 \u5751 6&#xff1a;\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u8fdb\u7a0b\u5361\u6b7b&#xff0c;\u65e0\u6cd5\u9000\u51fa<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u95ee\u9898&#xff1a;\u963b\u585e\u6a21\u5f0f\u4e0b&#xff0c;\u8fdb\u7a0b\u6253\u5f00\u7ba1\u9053\u540e&#xff0c;\u53e6\u4e00\u7aef\u4e00\u76f4\u672a\u6253\u5f00&#xff0c;\u5bfc\u81f4\u8fdb\u7a0b\u5361\u6b7b\u5728open()\u8c03\u7528&#xff0c;\u65e0\u6cd5\u9000\u51fa\u3002 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<li>\u4f7f\u7528\u4fe1\u53f7&#xff1a;\u4e3a\u8fdb\u7a0b\u6ce8\u518c\u4fe1\u53f7\u5904\u7406\u51fd\u6570&#xff08;\u5982 SIGINT&#xff09;&#xff0c;\u6355\u83b7 Ctrl&#043;C \u4fe1\u53f7&#xff0c;\u5728\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u4e2d\u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26\u5e76\u9000\u51fa&#xff1b;<\/li>\n<li>\u4f7f\u7528\u975e\u963b\u585e\u6a21\u5f0f&#xff1a;\u7ed3\u5408\u8f6e\u8be2&#xff0c;\u5b9e\u73b0\u975e\u963b\u585e\u7684\u7b49\u5f85\u903b\u8f91&#xff0c;\u907f\u514d\u8fdb\u7a0b\u5361\u6b7b&#xff1b;<\/li>\n<li>\u4f7f\u7528\u8d85\u65f6\u673a\u5236&#xff1a;\u901a\u8fc7<span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">alarm()<\/span><\/span>\u8bbe\u7f6e\u5b9a\u65f6\u5668&#xff0c;\u8d85\u65f6\u540e\u89e6\u53d1 SIGALRM \u4fe1\u53f7&#xff0c;\u9000\u51fa\u963b\u585e\u3002<\/li>\n<hr \/>\n<h2 id=\"%E6%80%BB%E7%BB%93\">\u603b\u7ed3<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u547d\u540d\u7ba1\u9053\u7684\u5b66\u4e60&#xff0c;\u4e0d\u4ec5\u8ba9\u6211\u4eec\u638c\u63e1\u4e86\u4e00\u79cd\u5b9e\u7528\u7684 IPC \u65b9\u5f0f&#xff0c;\u66f4\u8ba9\u6211\u4eec\u52a0\u6df1\u4e86\u5bf9 Linux \u201c\u4e00\u5207\u7686\u6587\u4ef6\u201d \u8bbe\u8ba1\u601d\u60f3\u7684\u7406\u89e3\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u547d\u540d\u7ba1\u9053\u867d\u7136\u4e0d\u5982 Socket \u529f\u80fd\u5f3a\u5927&#xff0c;\u4e0d\u5982\u5171\u4eab\u5185\u5b58\u901f\u5ea6\u5feb&#xff0c;\u4f46\u5b83\u4ee5\u8f7b\u91cf\u3001\u7b80\u5355\u3001\u6613\u7528\u7684\u7279\u70b9&#xff0c;\u5728\u672c\u5730\u8de8\u8fdb\u7a0b\u901a\u4fe1\u7684\u573a\u666f\u4e2d\u5360\u636e\u7740\u91cd\u8981\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f53\u7136&#xff0c;\u547d\u540d\u7ba1\u9053\u4e5f\u53ea\u662f Linux IPC \u5bb6\u65cf\u7684\u4e00\u5458&#xff0c;\u540e\u7eed\u8fd8\u53ef\u4ee5\u7ee7\u7eed\u5b66\u4e60\u5171\u4eab\u5185\u5b58&#xff08;\u6700\u5feb\u7684 IPC&#xff09;\u3001\u6d88\u606f\u961f\u5217&#xff08;\u6709\u6d88\u606f\u8fb9\u754c\u7684\u901a\u4fe1&#xff09;\u3001Socket&#xff08;\u8de8\u4e3b\u673a\u901a\u4fe1&#xff09;\u7b49\u65b9\u5f0f&#xff0c;\u6784\u5efa\u5b8c\u6574\u7684 Linux \u8fdb\u7a0b\u95f4\u901a\u4fe1\u77e5\u8bc6\u4f53\u7cfb\u3002\u4f46\u65e0\u8bba\u5b66\u4e60\u54ea\u79cd IPC \u65b9\u5f0f&#xff0c;\u547d\u540d\u7ba1\u9053\u7684\u57fa\u7840\u77e5\u8bc6\u548c\u8bbe\u8ba1\u601d\u60f3&#xff0c;\u90fd\u662f\u91cd\u8981\u7684\u94fa\u57ab\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5e0c\u671b\u672c\u6587\u80fd\u5e2e\u52a9\u4f60\u5f7b\u5e95\u5403\u900f\u547d\u540d\u7ba1\u9053&#xff0c;\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u7075\u6d3b\u8fd0\u7528&#xff0c;\u5b9e\u73b0\u9ad8\u6548\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u524d\u8a00<br \/>\n\u4e00\u3001\u547d\u540d\u7ba1\u9053\u7684\u8bde\u751f&#xff1a;\u89e3\u51b3\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u75db\u70b9<br \/>\n1.1 \u533f\u540d\u7ba1\u9053\u7684\u81f4\u547d\u77ed\u677f<br \/>\n1.2 \u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8bbe\u8ba1\u601d\u8def<br \/>\n1.3 \u547d\u540d\u7ba1\u9053\u4e0e\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u5173\u8054<br \/>\n\u4e8c\u3001\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8ba4\u77e5&#xff1a;\u4ec0\u4e48\u662f FIFO \u6587\u4ef6&#xff1f;<br \/>\n2.1 FIFO \u6587\u4ef6\u7684\u672c\u8d28<br \/>\n2.2 FIFO \u6587\u4ef6\u7684\u6807\u8bc6<br \/>\n2.3 \u547d\u540d\u7ba1\u9053\u7684\u901a\u4fe1\u6a21\u578b<br \/>\n\u4e09\u3001\u547d\u540d\u7ba1\u9053\u7684\u521b\u5efa&#xff1a;mkfifo () \u51fd\u6570\u4e0e\u547d\u4ee4\u884c<br \/>\n3.1 \u547d\u4ee4\u884c\u521b\u5efa\u547d\u540d\u7ba1\u9053<br \/>\n3.2 \u7a0b\u5e8f\u4e2d\u521b\u5efa\u547d\u540d\u7ba1\u9053<\/p>\n","protected":false},"author":2,"featured_media":75088,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7951,1054,58,2620,16,1714,6150],"topic":[],"class_list":["post-75090","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-fifo","tag-c-c","tag-linux","tag-2620","tag-16","tag-1714","tag-6150"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1 - \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\/75090.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u524d\u8a00 \u4e00\u3001\u547d\u540d\u7ba1\u9053\u7684\u8bde\u751f&#xff1a;\u89e3\u51b3\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u75db\u70b9 1.1 \u533f\u540d\u7ba1\u9053\u7684\u81f4\u547d\u77ed\u677f 1.2 \u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8bbe\u8ba1\u601d\u8def 1.3 \u547d\u540d\u7ba1\u9053\u4e0e\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u5173\u8054 \u4e8c\u3001\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8ba4\u77e5&#xff1a;\u4ec0\u4e48\u662f FIFO \u6587\u4ef6&#xff1f; 2.1 FIFO \u6587\u4ef6\u7684\u672c\u8d28 2.2 FIFO \u6587\u4ef6\u7684\u6807\u8bc6 2.3 \u547d\u540d\u7ba1\u9053\u7684\u901a\u4fe1\u6a21\u578b \u4e09\u3001\u547d\u540d\u7ba1\u9053\u7684\u521b\u5efa&#xff1a;mkfifo () \u51fd\u6570\u4e0e\u547d\u4ee4\u884c 3.1 \u547d\u4ee4\u884c\u521b\u5efa\u547d\u540d\u7ba1\u9053 3.2 \u7a0b\u5e8f\u4e2d\u521b\u5efa\u547d\u540d\u7ba1\u9053\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/75090.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-11T03:57:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260211035748-698bfe3c281fb.gif\" \/>\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=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/75090.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/75090.html\",\"name\":\"\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-11T03:57:50+00:00\",\"dateModified\":\"2026-02-11T03:57:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/75090.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/75090.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/75090.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1\"}]},{\"@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\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1 - \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\/75090.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u524d\u8a00 \u4e00\u3001\u547d\u540d\u7ba1\u9053\u7684\u8bde\u751f&#xff1a;\u89e3\u51b3\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u75db\u70b9 1.1 \u533f\u540d\u7ba1\u9053\u7684\u81f4\u547d\u77ed\u677f 1.2 \u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8bbe\u8ba1\u601d\u8def 1.3 \u547d\u540d\u7ba1\u9053\u4e0e\u533f\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u5173\u8054 \u4e8c\u3001\u547d\u540d\u7ba1\u9053\u7684\u6838\u5fc3\u8ba4\u77e5&#xff1a;\u4ec0\u4e48\u662f FIFO \u6587\u4ef6&#xff1f; 2.1 FIFO \u6587\u4ef6\u7684\u672c\u8d28 2.2 FIFO \u6587\u4ef6\u7684\u6807\u8bc6 2.3 \u547d\u540d\u7ba1\u9053\u7684\u901a\u4fe1\u6a21\u578b \u4e09\u3001\u547d\u540d\u7ba1\u9053\u7684\u521b\u5efa&#xff1a;mkfifo () \u51fd\u6570\u4e0e\u547d\u4ee4\u884c 3.1 \u547d\u4ee4\u884c\u521b\u5efa\u547d\u540d\u7ba1\u9053 3.2 \u7a0b\u5e8f\u4e2d\u521b\u5efa\u547d\u540d\u7ba1\u9053","og_url":"https:\/\/www.wsisp.com\/helps\/75090.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-11T03:57:50+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260211035748-698bfe3c281fb.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/75090.html","url":"https:\/\/www.wsisp.com\/helps\/75090.html","name":"\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-11T03:57:50+00:00","dateModified":"2026-02-11T03:57:50+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/75090.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/75090.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/75090.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Linux\u7cfb\u7edf\u7f16\u7a0b\u3011\uff08\u4e09\u5341\u4e8c\uff09\u547d\u540d\u7ba1\u9053 FIFO \u7cbe\u8bb2\uff1a\u7a81\u7834\u4eb2\u7f18\u9650\u5236\uff0c\u5b9e\u73b0\u4efb\u610f\u8fdb\u7a0b\u95f4\u7684 IPC \u901a\u4fe1"}]},{"@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\/75090","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=75090"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/75090\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/75088"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=75090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=75090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=75090"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=75090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}