{"id":35445,"date":"2025-05-04T13:50:31","date_gmt":"2025-05-04T05:50:31","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/35445.html"},"modified":"2025-05-04T13:50:31","modified_gmt":"2025-05-04T05:50:31","slug":"linux%e9%94%99%e8%af%af5%e7%a8%8b%e5%ba%8ffork%e5%ad%90%e8%bf%9b%e7%a8%8b%e5%90%8e%e8%ae%bf%e9%97%ae%e5%86%85%e5%ad%98%e8%a7%a6%e5%8f%91%e7%bc%ba%e9%a1%b5%e4%b8%ad%e6%96%adcow","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/35445.html","title":{"rendered":"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW)"},"content":{"rendered":"<h2>Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW)<\/h2>\n<p><b><font face=\"\u4eff\u5b8b\"> Author: Once Day Date: 2025\u5e743\u670812\u65e5<\/font><\/b> <\/p>\n<p><b><font face=\"\u4eff\u5b8b\">\u4e00\u4f4d\u70ed\u8877\u4e8eLinux\u5b66\u4e60\u548c\u5f00\u53d1\u7684\u83dc\u9e1f&#xff0c;\u8bd5\u56fe\u8c31\u5199\u4e00\u573a\u5192\u9669\u4e4b\u65c5&#xff0c;\u4e5f\u8bb8\u7ec8\u70b9\u53ea\u662f\u4e00\u573a\u767d\u65e5\u68a6\u2026<\/font><\/b> <\/p>\n<p><b><font face=\"\u4eff\u5b8b\"> \u6f2b\u6f2b\u957f\u8def&#xff0c;\u6709\u4eba\u5bf9\u4f60\u5fae\u7b11\u8fc7\u561b\u2026<\/font><\/b> <\/p>\n<p><b>\u5168\u7cfb\u5217\u6587\u7ae0\u53ef\u53c2\u8003\u4e13\u680f: Linux\u5b9e\u8df5\u8bb0\u5f55_Once_day\u7684\u535a\u5ba2-CSDN\u535a\u5ba2 <\/b><\/p>\n<p><b>\u53c2\u8003\u6587\u7ae0:<\/b><\/p>\n<ul>\n<li>\u76d1\u6d4b Linux \u5185\u5b58\u7f3a\u9875\u4e2d\u65ad\u4e8b\u4ef6 | \u9648\u8c2d\u519b\u7684\u535a\u5ba2 | tanjunchen Blog<\/li>\n<\/ul>\n<hr \/>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW)<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>1. \u95ee\u9898\u5206\u6790<\/li>\n<li>\n<ul>\n<li>1.1 \u73b0\u8c61\u4ecb\u7ecd<\/li>\n<li>1.2 \u5206\u6790\u539f\u56e0<\/li>\n<li>1.3 \u89e3\u51b3\u601d\u8def<\/li>\n<li>1.4 \u89e3\u51b3\u65b9\u6cd5<\/li>\n<li>1.5 posix_spawn\u548cvfork\u4ecb\u7ecd<\/li>\n<\/ul>\n<\/li>\n<li>2. \u5b9e\u4f8b\u9a8c\u8bc1<\/li>\n<li>\n<ul>\n<li>2.1 \u590d\u73b0\u6545\u969c<\/li>\n<li>2.2 \u4f7f\u7528vfork\u66ff\u4ee3fork<\/li>\n<li>2.3 \u4f7f\u7528posix_spawn<\/li>\n<\/ul>\n<\/li>\n<li>3. \u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>1. \u95ee\u9898\u5206\u6790<\/h5>\n<h6>1.1 \u73b0\u8c61\u4ecb\u7ecd<\/h6>\n<p>\u5728\u4e00\u4e2a\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u4e2d&#xff0c;\u4f7f\u7528 popen() \u521b\u5efa\u5b50\u8fdb\u7a0b\u540e&#xff0c;\u7cfb\u7edf\u51fa\u73b0\u4e86\u5927\u91cf\u7f3a\u9875\u4e2d\u65ad&#xff08;Page Fault&#xff09;&#xff0c;\u5bfc\u81f4\u77ac\u95f4\u7a81\u53d1\u8017\u65f6&#xff08;\u7ea6 50ms&#xff09;\u3002\u7531\u4e8e popen() \u672c\u8d28\u4e0a\u8c03\u7528\u4e86 fork()&#xff0c;\u800c fork() \u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u53ef\u80fd\u4f1a\u89e6\u53d1\u5199\u65f6\u62f7\u8d1d&#xff08;Copy-On-Write, COW&#xff09;&#xff0c;\u8fdb\u800c\u5bfc\u81f4\u5185\u5b58\u9875\u590d\u5236&#xff0c;\u5f15\u53d1\u6027\u80fd\u6296\u52a8\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250504055030-68170026b0d85.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h6>1.2 \u5206\u6790\u539f\u56e0<\/h6>\n<p>\u5728\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u4e2d\u8c03\u7528 popen()&#xff0c;\u5176\u5185\u90e8\u4f1a\u6267\u884c fork() \u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u800c fork() \u540e\u7684\u5b50\u8fdb\u7a0b\u4f1a\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4&#xff08;COW \u673a\u5236&#xff09;\u3002\u5982\u679c\u5728 fork() \u4e4b\u540e&#xff0c;\u7236\u8fdb\u7a0b\u6216\u5b50\u8fdb\u7a0b\u4fee\u6539\u4e86\u5171\u4eab\u5185\u5b58\u9875&#xff0c;\u5219\u4f1a\u89e6\u53d1 COW&#xff0c;\u5bfc\u81f4\u5927\u89c4\u6a21\u9875\u590d\u5236&#xff0c;\u4ece\u800c\u5f15\u53d1\u7f3a\u9875\u4e2d\u65ad\u548c\u6027\u80fd\u4e0b\u964d\u3002<\/p>\n<p>&#xff08;1&#xff09;COW \u89e6\u53d1\u5927\u91cf\u9875\u590d\u5236<\/p>\n<ul>\n<li>fork() \u4e4b\u540e&#xff0c;\u7236\u5b50\u8fdb\u7a0b\u5171\u4eab\u76f8\u540c\u7684\u9875\u9762&#xff0c;\u5e76\u6807\u8bb0\u4e3a\u5199\u65f6\u62f7\u8d1d&#xff08;COW&#xff09;\u3002<\/li>\n<li>\u5982\u679c\u7236\u8fdb\u7a0b\u6216\u5b50\u8fdb\u7a0b\u4fee\u6539\u8fd9\u4e9b\u9875\u9762&#xff0c;\u5c31\u4f1a\u89e6\u53d1COW \u673a\u5236&#xff0c;\u5bfc\u81f4\u5185\u6838\u5206\u914d\u65b0\u9875\u9762\u5e76\u590d\u5236\u6570\u636e&#xff0c;\u8fdb\u800c\u5f15\u53d1\u7f3a\u9875\u5f02\u5e38\u548c\u989d\u5916\u7684 CPU\/\u5185\u5b58\u5f00\u9500\u3002<\/li>\n<\/ul>\n<p>&#xff08;2&#xff09;\u591a\u7ebf\u7a0b\u73af\u5883\u5bfc\u81f4 fork() \u7ee7\u627f\u5927\u91cf\u9875<\/p>\n<ul>\n<li>\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u7684\u5806&#xff08;heap&#xff09;\u3001\u6808&#xff08;stack&#xff09;\u7b49\u6570\u636e\u7ed3\u6784\u8f83\u4e3a\u590d\u6742&#xff0c;fork() \u590d\u5236\u7684\u9875\u8868\u8f83\u591a&#xff0c;\u589e\u52a0\u4e86COW \u89e6\u53d1\u7684\u6982\u7387\u3002<\/li>\n<li>malloc() \u53ef\u80fd\u5728 fork() \u4e4b\u524d\u5206\u914d\u4e86\u5927\u91cf\u5185\u5b58&#xff0c;\u800c fork() \u4e4b\u540e&#xff0c;glibc \u7684 malloc \u53ef\u80fd\u4f1a\u5728\u5b50\u8fdb\u7a0b\u6267\u884c exec() \u4e4b\u524d\u89e6\u53d1COW\u3002<\/li>\n<\/ul>\n<p>&#xff08;3&#xff09;TLB&#xff08;Translation Lookaside Buffer&#xff09;\u5931\u6548<\/p>\n<ul>\n<li>fork() \u4e4b\u540e&#xff0c;\u5b50\u8fdb\u7a0b\u5bf9\u5171\u4eab\u7684\u5185\u5b58\u8fdb\u884c\u5199\u64cd\u4f5c&#xff0c;\u5bfc\u81f4TLB \u5931\u6548&#xff0c;\u8fdb\u800c\u5f71\u54cd\u6027\u80fd\u3002<\/li>\n<\/ul>\n<p>&#xff08;4&#xff09;popen() \u5185\u90e8\u5b9e\u73b0\u4f7f\u7528\u4e86 fork()<\/p>\n<ul>\n<li>popen() \u672c\u8d28\u4e0a\u662f fork() &#043; exec() &#043; pipe()&#xff0c;\u5bfc\u81f4fork() \u7ee7\u627f\u4e86\u7236\u8fdb\u7a0b\u7684\u6240\u6709\u5730\u5740\u7a7a\u95f4&#xff0c;\u589e\u52a0\u4e86COW \u89e6\u53d1\u53ef\u80fd\u6027\u3002<\/li>\n<\/ul>\n<h6>1.3 \u89e3\u51b3\u601d\u8def<\/h6>\n<p>\u8981\u51cf\u5c11 fork() \u89e6\u53d1\u7684COW \u53ca\u7f3a\u9875\u4e2d\u65ad&#xff0c;\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u56db\u4e2a\u89d2\u5ea6\u8fdb\u884c\u4f18\u5316&#xff1a;<\/p>\n<ul>\n<li>\u907f\u514d fork() \u4e4b\u540e\u7684\u5185\u5b58\u5199\u5165&#xff0c;\u51cf\u5c11 COW \u89e6\u53d1\u3002<\/li>\n<li>\u4f7f\u7528 vfork() \u4ee3\u66ff fork()&#xff0c;\u51cf\u5c11\u9875\u8868\u590d\u5236\u3002<\/li>\n<li>\u4f7f\u7528 posix_spawn() \u4ee3\u66ff fork()&#043;exec()&#xff0c;\u907f\u514d COW\u3002<\/li>\n<li>\u4f18\u5316 malloc \u53ca mmap \u884c\u4e3a&#xff0c;\u51cf\u5c11 fork() \u7ee7\u627f\u7684\u9875\u9762\u3002<\/li>\n<\/ul>\n<h6>1.4 \u89e3\u51b3\u65b9\u6cd5<\/h6>\n<p>&#xff08;1&#xff09;\u9884\u9632 COW \u89e6\u53d1&#xff0c;\u51cf\u5c11 fork() \u7ee7\u627f\u7684\u5185\u5b58\u3002<\/p>\n<ul>\n<li>\n<p>fork() \u4e4b\u524d\u8c03\u7528 madvise(MADV_DONTNEED)&#xff0c;madvise() \u53ef\u91ca\u653e\u4e0d\u5fc5\u8981\u7684\u5185\u5b58&#xff0c;\u51cf\u5c11 fork() \u7ee7\u627f\u7684\u9875\u9762&#xff0c;\u964d\u4f4e COW \u89e6\u53d1\u6982\u7387\u3002<\/p>\n<p> <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>ptr <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">malloc<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1024<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5206\u914d 1MB \u5185\u5b58<\/span><br \/>\n<span class=\"token function\">madvise<\/span><span class=\"token punctuation\">(<\/span>ptr<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1024<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">,<\/span> MADV_DONTNEED<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u91ca\u653e\u7269\u7406\u9875<\/span>\n <\/li>\n<li>\n<p>fork() \u4e4b\u524d\u8c03\u7528 malloc_trim()&#xff0c;malloc_trim() \u8ba9 glibc \u91ca\u653e\u672a\u4f7f\u7528\u7684\u5806&#xff0c;\u51cf\u5c11 fork() \u7ee7\u627f\u7684\u9875\u3002<\/p>\n<p> <span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;malloc.h&gt;<\/span><\/span><br \/>\n<span class=\"token function\">malloc_trim<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u91ca\u653e\u7a7a\u95f2\u5806\u5185\u5b58<\/span>\n <\/li>\n<li>\n<p>\u907f\u514d fork() \u4e4b\u540e\u4fee\u6539\u5168\u5c40\u53d8\u91cf&#xff0c;fork() \u4e4b\u540e&#xff0c;\u5c3d\u91cf\u4e0d\u8981\u4fee\u6539\u5171\u4eab\u5185\u5b58&#xff08;\u5982\u5168\u5c40\u53d8\u91cf\u3001\u5806\u53d8\u91cf&#xff09;&#xff0c;\u9632\u6b62\u89e6\u53d1 COW\u3002<\/p>\n<\/li>\n<\/ul>\n<p>&#xff08;2&#xff09;\u4f7f\u7528 vfork() \u4ee3\u66ff fork()\u3002<\/p>\n<ul>\n<li>\n<p>vfork()\u4e0d\u4f1a\u590d\u5236\u5730\u5740\u7a7a\u95f4&#xff0c;\u5b50\u8fdb\u7a0b\u76f4\u63a5\u5171\u4eab\u7236\u8fdb\u7a0b\u7684\u5185\u5b58&#xff0c;\u907f\u514d COW \u89e6\u53d1\u3002<\/p>\n<\/li>\n<li>\n<p>\u9002\u7528\u4e8e\u5b50\u8fdb\u7a0b\u7acb\u5373\u6267\u884c exec()\u7684\u573a\u666f\u3002<\/p>\n<p> <span class=\"token class-name\">pid_t<\/span> pid <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">vfork<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>pid <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">execlp<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;ls&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;ls&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u7acb\u5373 exec()&#xff0c;\u907f\u514d\u4fee\u6539\u5185\u5b58<\/span><br \/>\n    <span class=\"token function\">_exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u5931\u8d25\u9000\u51fa<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>\n <\/li>\n<li>\n<p>\u6ce8\u610f&#xff1a; vfork() \u4f1a\u963b\u585e\u7236\u8fdb\u7a0b&#xff0c;\u9002\u7528\u4e8e exec() \u7acb\u5373\u66ff\u6362\u8fdb\u7a0b\u7684\u573a\u666f\u3002<\/p>\n<\/li>\n<\/ul>\n<p>&#xff08;3&#xff09;\u4f7f\u7528 posix_spawn() \u4ee3\u66ff fork()&#043;exec()\u3002<\/p>\n<ul>\n<li>\n<p>posix_spawn()\u5e95\u5c42\u53ef\u907f\u514d fork() \u7ee7\u627f\u5927\u91cf\u9875\u9762&#xff0c;\u51cf\u5c11 COW \u89e6\u53d1\u3002<\/p>\n<\/li>\n<li>\n<p>\u9002\u7528\u4e8e\u521b\u5efa\u5b50\u8fdb\u7a0b\u5e76\u6267\u884c\u65b0\u7a0b\u5e8f\u7684\u573a\u666f\u3002<\/p>\n<p> <span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;spawn.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">extern<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>environ<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token class-name\">pid_t<\/span> pid<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">posix_spawn<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>pid<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\/bin\/ls&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token keyword\">const<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;ls&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> environ<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<li>\n<p>\u6bd4 fork()&#043;exec() \u66f4\u5feb&#xff0c;\u907f\u514d fork() \u590d\u5236\u9875\u9762\u3002\u51cf\u5c11\u7f3a\u9875\u4e2d\u65ad&#xff0c;\u63d0\u9ad8\u521b\u5efa\u5b50\u8fdb\u7a0b\u7684\u6548\u7387\u3002<\/p>\n<\/li>\n<\/ul>\n<p>&#xff08;4&#xff09;\u907f\u514d malloc \u53ca mmap \u5f71\u54cd fork()&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528 pthread_atfork() \u4fdd\u62a4 malloc()&#xff0c;pthread_atfork() \u53ef\u5728 fork() \u4e4b\u524d\u9501\u5b9a malloc&#xff0c;\u9632\u6b62 COW \u5f71\u54cd\u3002<\/p>\n<p> <span class=\"token function\">pthread_atfork<\/span><span class=\"token punctuation\">(<\/span>lock_malloc<span class=\"token punctuation\">,<\/span> unlock_malloc<span class=\"token punctuation\">,<\/span> unlock_malloc<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<li>\n<p>\u907f\u514d\u5728 fork() \u4e4b\u540e\u8c03\u7528 malloc()&#xff0c;malloc() \u53ef\u80fd\u4fee\u6539 glibc \u7684 heap \u7ed3\u6784&#xff0c;\u5bfc\u81f4COW\u89e6\u53d1&#xff0c;\u5efa\u8bae\u5728 fork() \u4e4b\u524d\u9884\u5206\u914d\u5185\u5b58\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528 mmap() \u4ee3\u66ff malloc()&#xff0c;mmap() \u5206\u914d\u7684\u533f\u540d\u6620\u5c04\u9875\u53ef\u4ee5\u907f\u514d COW&#xff0c;\u9002\u7528\u4e8e\u5927\u5757\u5185\u5b58\u5206\u914d\u3002<\/p>\n<p> <span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>ptr <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">mmap<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">4096<\/span><span class=\"token punctuation\">,<\/span> PROT_READ <span class=\"token operator\">|<\/span> PROT_WRITE<span class=\"token punctuation\">,<\/span> MAP_PRIVATE <span class=\"token operator\">|<\/span> MAP_ANONYMOUS<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<\/ul>\n<table>\n<tr>\u4f18\u5316\u70b9\u4f18\u5316\u65b9\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>\u51cf\u5c11 fork() \u7ee7\u627f\u7684\u5185\u5b58<\/td>\n<td>madvise(MADV_DONTNEED), malloc_trim(0)<\/td>\n<\/tr>\n<tr>\n<td>\u907f\u514d fork() \u540e COW \u89e6\u53d1<\/td>\n<td>\u907f\u514d\u4fee\u6539\u5168\u5c40\u53d8\u91cf&#xff0c;\u907f\u514d malloc()<\/td>\n<\/tr>\n<tr>\n<td>\u6539\u7528 vfork() \u907f\u514d COW<\/td>\n<td>vfork() \u9002\u7528\u4e8e exec() \u573a\u666f<\/td>\n<\/tr>\n<tr>\n<td>\u4f7f\u7528 posix_spawn() \u4ee3\u66ff fork()<\/td>\n<td>\u66f4\u9ad8\u6548&#xff0c;\u51cf\u5c11\u7f3a\u9875\u4e2d\u65ad<\/td>\n<\/tr>\n<tr>\n<td>\u4f18\u5316 malloc \u53ca mmap \u884c\u4e3a<\/td>\n<td>pthread_atfork(), mmap()<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h6>1.5 posix_spawn\u548cvfork\u4ecb\u7ecd<\/h6>\n<p>posix_spawn() \u662f\u521b\u5efa\u5b50\u8fdb\u7a0b\u5e76\u6267\u884c\u65b0\u7a0b\u5e8f\u7684\u9ad8\u6548\u65b9\u6cd5&#xff0c;\u901a\u5e38\u7528\u4e8e\u66ff\u4ee3 fork()&#043;exec() \u7ec4\u5408\u3002<\/p>\n<ul>\n<li>\u907f\u514d fork() \u7ee7\u627f\u5927\u91cf\u5730\u5740\u7a7a\u95f4&#xff0c;\u51cf\u5c11\u5199\u65f6\u62f7\u8d1d&#xff08;COW&#xff09;\u548c\u7f3a\u9875\u4e2d\u65ad\u3002<\/li>\n<li>\u5b9e\u73b0\u65b9\u5f0f\u56e0\u7cfb\u7edf\u4e0d\u540c&#xff0c;\u5728Linux&#xff0c;posix_spawn() \u53ef\u80fd\u4f7f\u7528 vfork() \u8fdb\u884c\u4f18\u5316\u3002\u5728macOS&#xff0c;posix_spawn() \u662f\u7cfb\u7edf\u8c03\u7528&#xff0c;\u6bd4 fork()&#043;exec() \u66f4\u9ad8\u6548\u3002<\/li>\n<li>\u9002\u7528\u4e8e\u521b\u5efa\u5b50\u8fdb\u7a0b\u5e76\u7acb\u5373\u6267\u884c\u65b0\u7a0b\u5e8f\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n<p>vfork() \u662f fork() \u7684\u4f18\u5316\u7248\u672c&#xff0c;\u5b50\u8fdb\u7a0b\u76f4\u63a5\u5171\u4eab\u7236\u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4&#xff0c;\u4e0d\u4f1a\u590d\u5236\u9875\u8868\u3002<\/p>\n<ul>\n<li>\u5b50\u8fdb\u7a0b\u4e0e\u7236\u8fdb\u7a0b\u5171\u4eab\u5730\u5740\u7a7a\u95f4&#xff0c;\u907f\u514d fork() \u7684COW \u673a\u5236\u548cTLB \u5931\u6548\u3002<\/li>\n<li>\u5b50\u8fdb\u7a0b\u6267\u884cexec()\u4e4b\u524d&#xff0c;\u4e0d\u80fd\u4fee\u6539\u5185\u5b58&#xff0c;\u5426\u5219\u53ef\u80fd\u5f71\u54cd\u7236\u8fdb\u7a0b\u3002<\/li>\n<li>\u7236\u8fdb\u7a0b\u4f1a\u88ab\u963b\u585e&#xff0c;\u76f4\u5230\u5b50\u8fdb\u7a0bexec() \u6216 _exit() \u9000\u51fa\u3002<\/li>\n<\/ul>\n<table>\n<tr>\u7279\u6027posix_spawn()vfork()<\/tr>\n<tbody>\n<tr>\n<td>\u907f\u514d fork() \u9875\u8868\u590d\u5236<\/td>\n<td>\u2705 \u662f<\/td>\n<td>\u2705 \u662f<\/td>\n<\/tr>\n<tr>\n<td>\u5b50\u8fdb\u7a0b\u5171\u4eab\u7236\u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4<\/td>\n<td>\u274c \u5426<\/td>\n<td>\u2705 \u662f<\/td>\n<\/tr>\n<tr>\n<td>\u7236\u8fdb\u7a0b\u662f\u5426\u88ab\u963b\u585e<\/td>\n<td>\u274c \u5426<\/td>\n<td>\u2705 \u662f<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u4e8e exec() \u4e4b\u540e\u7684\u573a\u666f<\/td>\n<td>\u2705 \u662f<\/td>\n<td>\u2705 \u662f<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u4e8e\u590d\u6742\u5b50\u8fdb\u7a0b\u542f\u52a8<\/td>\n<td>\u2705 \u662f<\/td>\n<td>\u274c \u5426<\/td>\n<\/tr>\n<tr>\n<td>\u5b9e\u73b0\u65b9\u5f0f<\/td>\n<td>fork() \u6216 vfork()&#xff08;\u5e73\u53f0\u76f8\u5173&#xff09;<\/td>\n<td>\u76f4\u63a5\u5171\u4eab\u5730\u5740\u7a7a\u95f4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>posix_spawn() \u9002\u7528\u4e8e\u4e00\u822c fork()&#043;exec() \u66ff\u4ee3\u65b9\u6848&#xff0c;\u907f\u514d fork() \u7ee7\u627f\u5927\u91cf\u5185\u5b58\u3002<\/p>\n<p>vfork() \u9002\u7528\u4e8e exec() \u7acb\u5373\u6267\u884c\u7684\u60c5\u51b5&#xff0c;\u4f46\u4e0d\u9002\u5408\u590d\u6742\u5b50\u8fdb\u7a0b\u903b\u8f91\u3002<\/p>\n<h5>2. \u5b9e\u4f8b\u9a8c\u8bc1<\/h5>\n<h6>2.1 \u590d\u73b0\u6545\u969c<\/h6>\n<p>\u4f7f\u7528\u4e0b\u8ff0\u7684\u4ee3\u7801\u53ef\u4ee5\u590d\u73b0fork\u548cexec\u4e4b\u95f4\u7236\u8fdb\u7a0b\u4fee\u6539\u5806\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad\u7684\u60c5\u51b5\u3002<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">_GNU_SOURCE<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">__USE_GNU<\/span><\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/wait.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;pthread.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sched.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/mman.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">volatile<\/span> <span class=\"token keyword\">int<\/span> thread_stop  <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span>          enable_write <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">writeaddr<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>addr<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">4096<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        addr<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> i<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">thread_func<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span>arg<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u7ed1\u5b9a\u7ebf\u7a0b 3 \u53f7 CPU<\/span><br \/>\n    <span class=\"token class-name\">cpu_set_t<\/span> mask<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">CPU_ZERO<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">CPU_SET<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">pthread_setaffinity_np<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">pthread_self<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;thread_func\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ char *p2 &#061; malloc(4096 * 100);<\/span><br \/>\n    <span class=\"token comment\">\/\/ memset(p2, 0x0, 4096 * 100);<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ sleep();<\/span><br \/>\n    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>thread_stop<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>enable_write<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token function\">writeaddr<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span>arg <span class=\"token operator\">&#043;<\/span> i <span class=\"token operator\">*<\/span> <span class=\"token number\">4096<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ argv[1] \u4e3a 1 \u65f6&#xff0c;\u6d4b\u8bd5\u7f3a\u9875\u4e2d\u65ad(COW)<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> enable_fork <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>argc <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        enable_fork <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>argc <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        enable_write <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>p <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">malloc<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">4096<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">memset<\/span><span class=\"token punctuation\">(<\/span>p<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0x0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">4096<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">100<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u7ed1\u5b9a 2 \u53f7 CPU<\/span><br \/>\n    <span class=\"token class-name\">cpu_set_t<\/span> mask<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">CPU_ZERO<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">CPU_SET<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">sched_setaffinity<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>mask<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u521b\u5efa\u7ebf\u7a0b\u6267\u884c writeaddr<\/span><br \/>\n    <span class=\"token class-name\">pthread_t<\/span> tid<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">pthread_create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>tid<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">,<\/span> thread_func<span class=\"token punctuation\">,<\/span> p<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u7b49\u5f85\u540c\u6b65<\/span><br \/>\n    <span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ fork \u4e00\u4e2a\u5b50\u8fdb\u7a0b<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>enable_fork<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> pid <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">fork<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>pid <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token function\">execl<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\/bin\/echo&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;echo&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token function\">exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>enable_fork<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u7b49\u5f85\u5b50\u8fdb\u7a0b\u7ed3\u675f<\/span><br \/>\n        <span class=\"token function\">wait<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    thread_stop <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u7b49\u5f85\u7ebf\u7a0b\u7ed3\u675f<\/span><br \/>\n    <span class=\"token function\">pthread_join<\/span><span class=\"token punctuation\">(<\/span>tid<span class=\"token punctuation\">,<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4eceperf stat\u8ba1\u6570\u53ef\u4ee5\u660e\u663e\u770b\u51fa&#xff0c;fork\u5b50\u8fdb\u7a0b\u540e&#xff0c;\u7236\u8fdb\u7a0b\u7684\u5de5\u4f5c\u7ebf\u7a0b\u8bfb\u5199\u5806\u5185\u5b58&#xff0c;\u4f1a\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad&#xff0c;\u5927\u6982\u521a\u597d100&#043;(\u4e00\u4e2a\u9875\u97624KB)\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250504055030-68170026c0c9a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h6>2.2 \u4f7f\u7528vfork\u66ff\u4ee3fork<\/h6>\n<p>\u8fd9\u91cc\u4f7f\u7528vfork\u66ff\u4ee3fork&#xff0c;\u4ece\u4e0b\u56fe\u53ef\u4ee5\u770b\u5230&#xff0c;\u7f3a\u9875\u4e2d\u65ad\u4e0d\u518d\u589e\u52a0&#xff0c;\u56e0\u4e3a\u7236\u8fdb\u7a0b\u88ab\u5835\u585e\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250504055030-68170026d2bcb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4ece\u5835\u585e\u7684\u65f6\u95f4\u6765\u770b&#xff0c;\u65f6\u95f4\u8f83\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad\u8fd8\u8981\u77ed\u4e00\u4e9b&#xff1a;<\/p>\n<p>max_time<span class=\"token operator\">:<\/span> <span class=\"token number\">1556610<\/span> ns <span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&gt;<\/span> \u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad fork<br \/>\nmax_time<span class=\"token operator\">:<\/span> <span class=\"token number\">1121580<\/span> ns <span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&gt;<\/span> \u4e0d\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad vfork<\/p>\n<p>\u5e76\u4e14&#xff0c;\u53ea\u6709\u8c03\u7528vfork\u7684\u7ebf\u7a0b\u4f1a\u88ab\u5835\u585e&#xff0c;\u5176\u4ed6\u7ebf\u7a0b\u5e76\u672a\u88ab\u5835\u585e\u3002<\/p>\n<h6>2.3 \u4f7f\u7528posix_spawn<\/h6>\n<p>\u4f7f\u7528posix_spawn\u7684\u6548\u679c\u4e0evfork\u7c7b\u4f3c&#xff0c;\u5982\u4e0b:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250504055030-68170026e4622.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h5>3. \u603b\u7ed3<\/h5>\n<p>\u5728Linux\u73af\u5883\u4e0b&#xff0c;\u5982\u679c\u4e00\u4e2a\u7a0b\u5e8f\u9700\u8981\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u5982\u679c\u8fd9\u4e2a\u7a0b\u5e8f\u81ea\u8eab\u662f\u4e00\u4e2a\u590d\u6742\u7684\u591a\u7ebf\u7a0b\u7a0b\u5e8f&#xff0c;\u6700\u597d\u4e0d\u8981\u901a\u8fc7popen\u7b49\u63a5\u53e3\u8fd0\u884c\u811a\u672c&#xff0c;\u56e0\u4e3a\u8fd9\u53ef\u80fd\u9020\u6210\u7236\u8fdb\u7a0b\u4e2d\u5176\u4ed6\u7ebf\u7a0b\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad&#xff0c;\u9020\u6210\u670d\u52a1\u6ce2\u52a8\u3002<\/p>\n<p>\u5982\u679c\u9700\u8981\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u6700\u597d\u901a\u8fc7vfork\u6216\u8005posix_spawn\u63a5\u53e3&#xff0c;\u6307\u5b9a\u5b50\u8fdb\u7a0b\u7684\u5c5e\u6027&#xff0c;\u6bd4\u5982\u907f\u514d\u590d\u5236\u9875\u8868&#xff0c;\u76f4\u63a5\u5171\u4eab\u5185\u5b58\u7a7a\u95f4&#xff0c;\u7136\u540e\u5b50\u8fdb\u7a0b\u5feb\u901f\u6267\u884cexec\u5207\u6362\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n<p>\u5bf9\u4e8e\u65f6\u5ef6\u654f\u611f\u6027\u5e94\u7528&#xff0c;\u66f4\u5408\u9002\u7684\u505a\u6cd5\u662f\u901a\u8fc7\u4e00\u4e2a\u4ee3\u7406\u8fdb\u7a0b\u6765\u6267\u884cshell\u6216\u8005\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u7136\u540e\u901a\u8fc7RPC\u8fdb\u884c\u901a\u4fe1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.7k\u6b21\uff0c\u70b9\u8d5e45\u6b21\uff0c\u6536\u85cf55\u6b21\u3002\u5728\u4e00\u4e2a\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u7528popen()\u521b\u5efa\u5b50\u8fdb\u7a0b\u540e\uff0c\u7cfb\u7edf\u51fa\u73b0\u4e86\u5927\u91cf\u7f3a\u9875\u4e2d\u65ad\uff08Page Fault\uff09\uff0c\u5bfc\u81f4\u77ac\u95f4\u7a81\u53d1\u8017\u65f6\uff08\u7ea6 50ms\uff09\u3002\u7531\u4e8epopen()\u672c\u8d28\u4e0a\u8c03\u7528\u4e86fork()\uff0c\u800cfork()\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u53ef\u80fd\u4f1a\u89e6\u53d1\u5199\u65f6\u62f7\u8d1d\uff08Copy-On-Write, COW\uff09\uff0c\u8fdb\u800c\u5bfc\u81f4\u5185\u5b58\u9875\u590d\u5236\uff0c\u5f15\u53d1\u6027\u80fd\u6296\u52a8\u3002\u662f\u521b\u5efa\u5b50\u8fdb\u7a0b\u5e76\u6267\u884c\u65b0\u7a0b\u5e8f\u7684\u9ad8\u6548\u65b9\u6cd5\uff0c\u901a\u5e38\u7528\u4e8e\u66ff\u4ee3\u7ec4\u5408\u3002\u907f\u514dfork()\u7ee7\u627f\u5927\u91cf\u5730\u5740\u7a7a\u95f4\uff0c\u51cf\u5c11\u5199\u65f6\u62f7\u8d1d\uff08COW\uff09\u548c\u7f3a\u9875\u4e2d\u65ad\u3002\u5b9e\u73b0\u65b9\u5f0f\u56e0\u7cfb\u7edf\u4e0d\u540c\uff0c\u5728Linux\uff0c\u53ef\u80fd\u4f7f\u7528vfork()\u8fdb\u884c\u4f18\u5316\u3002\u5728macOS\uff0c<\/p>\n","protected":false},"author":2,"featured_media":35441,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3031,58,43,44],"topic":[],"class_list":{"0":"post-35445","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-linux","10":"tag-43","11":"tag-44"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW) - \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\/35445.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.7k\u6b21\uff0c\u70b9\u8d5e45\u6b21\uff0c\u6536\u85cf55\u6b21\u3002\u5728\u4e00\u4e2a\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u7528popen()\u521b\u5efa\u5b50\u8fdb\u7a0b\u540e\uff0c\u7cfb\u7edf\u51fa\u73b0\u4e86\u5927\u91cf\u7f3a\u9875\u4e2d\u65ad\uff08Page Fault\uff09\uff0c\u5bfc\u81f4\u77ac\u95f4\u7a81\u53d1\u8017\u65f6\uff08\u7ea6 50ms\uff09\u3002\u7531\u4e8epopen()\u672c\u8d28\u4e0a\u8c03\u7528\u4e86fork()\uff0c\u800cfork()\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u53ef\u80fd\u4f1a\u89e6\u53d1\u5199\u65f6\u62f7\u8d1d\uff08Copy-On-Write, COW\uff09\uff0c\u8fdb\u800c\u5bfc\u81f4\u5185\u5b58\u9875\u590d\u5236\uff0c\u5f15\u53d1\u6027\u80fd\u6296\u52a8\u3002\u662f\u521b\u5efa\u5b50\u8fdb\u7a0b\u5e76\u6267\u884c\u65b0\u7a0b\u5e8f\u7684\u9ad8\u6548\u65b9\u6cd5\uff0c\u901a\u5e38\u7528\u4e8e\u66ff\u4ee3\u7ec4\u5408\u3002\u907f\u514dfork()\u7ee7\u627f\u5927\u91cf\u5730\u5740\u7a7a\u95f4\uff0c\u51cf\u5c11\u5199\u65f6\u62f7\u8d1d\uff08COW\uff09\u548c\u7f3a\u9875\u4e2d\u65ad\u3002\u5b9e\u73b0\u65b9\u5f0f\u56e0\u7cfb\u7edf\u4e0d\u540c\uff0c\u5728Linux\uff0c\u53ef\u80fd\u4f7f\u7528vfork()\u8fdb\u884c\u4f18\u5316\u3002\u5728macOS\uff0c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/35445.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-04T05:50:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250504055030-68170026b0d85.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/35445.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/35445.html\",\"name\":\"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-04T05:50:31+00:00\",\"dateModified\":\"2025-05-04T05:50:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/35445.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/35445.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/35445.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW) - \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\/35445.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.7k\u6b21\uff0c\u70b9\u8d5e45\u6b21\uff0c\u6536\u85cf55\u6b21\u3002\u5728\u4e00\u4e2a\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u7528popen()\u521b\u5efa\u5b50\u8fdb\u7a0b\u540e\uff0c\u7cfb\u7edf\u51fa\u73b0\u4e86\u5927\u91cf\u7f3a\u9875\u4e2d\u65ad\uff08Page Fault\uff09\uff0c\u5bfc\u81f4\u77ac\u95f4\u7a81\u53d1\u8017\u65f6\uff08\u7ea6 50ms\uff09\u3002\u7531\u4e8epopen()\u672c\u8d28\u4e0a\u8c03\u7528\u4e86fork()\uff0c\u800cfork()\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u53ef\u80fd\u4f1a\u89e6\u53d1\u5199\u65f6\u62f7\u8d1d\uff08Copy-On-Write, COW\uff09\uff0c\u8fdb\u800c\u5bfc\u81f4\u5185\u5b58\u9875\u590d\u5236\uff0c\u5f15\u53d1\u6027\u80fd\u6296\u52a8\u3002\u662f\u521b\u5efa\u5b50\u8fdb\u7a0b\u5e76\u6267\u884c\u65b0\u7a0b\u5e8f\u7684\u9ad8\u6548\u65b9\u6cd5\uff0c\u901a\u5e38\u7528\u4e8e\u66ff\u4ee3\u7ec4\u5408\u3002\u907f\u514dfork()\u7ee7\u627f\u5927\u91cf\u5730\u5740\u7a7a\u95f4\uff0c\u51cf\u5c11\u5199\u65f6\u62f7\u8d1d\uff08COW\uff09\u548c\u7f3a\u9875\u4e2d\u65ad\u3002\u5b9e\u73b0\u65b9\u5f0f\u56e0\u7cfb\u7edf\u4e0d\u540c\uff0c\u5728Linux\uff0c\u53ef\u80fd\u4f7f\u7528vfork()\u8fdb\u884c\u4f18\u5316\u3002\u5728macOS\uff0c","og_url":"https:\/\/www.wsisp.com\/helps\/35445.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-04T05:50:31+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250504055030-68170026b0d85.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/35445.html","url":"https:\/\/www.wsisp.com\/helps\/35445.html","name":"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-04T05:50:31+00:00","dateModified":"2025-05-04T05:50:31+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/35445.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/35445.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/35445.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u9519\u8bef(5)\u7a0b\u5e8ffork\u5b50\u8fdb\u7a0b\u540e\u8bbf\u95ee\u5185\u5b58\u89e6\u53d1\u7f3a\u9875\u4e2d\u65ad(COW)"}]},{"@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\/35445","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=35445"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/35445\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/35441"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=35445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=35445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=35445"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=35445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}