{"id":395,"date":"2016-08-19T13:42:43","date_gmt":"2016-08-19T05:42:43","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=395"},"modified":"2016-08-30T14:43:42","modified_gmt":"2016-08-30T06:43:42","slug":"wait%e5%92%8cwaitpid%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=395","title":{"rendered":"wait\u548cwaitpid\u51fd\u6570"},"content":{"rendered":"<p>\u65e0\u8bba\u8fdb\u7a0b\u662f\u6b63\u5e38\u7ed3\u675f\u8fd8\u662f\u975e\u6b63\u5e38\u7ed3\u675f\uff0c\u5185\u6838\u90fd\u4f1a\u53d1\u9001<span style=\"color: #993300;\">SIGCHLD<\/span>\u4fe1\u53f7\u7ed9\u5b83\u7684\u7236\u8fdb\u7a0b\uff0c\u4ee5\u544a\u77e5\u5b50\u8fdb\u7a0b\u7ed3\u675f\u3002\u56e0\u4e3a\u5b50\u8fdb\u7a0b\u7ed3\u675f\u662f\u4e00\u4e2a\u5f02\u6b65\u4e8b\u4ef6\uff0c\u5b83\u53ef\u4ee5\u53d1\u751f\u5728\u4efb\u4f55\u7236\u8fdb\u7a0b\u8fd0\u884c\u7684\u65f6\u95f4\uff0c\u8fd9\u4e2a\u4fe1\u53f7\u4e5f\u662f\u7531\u5185\u6838\u5f02\u6b65\u901a\u77e5\u7236\u8fdb\u7a0b\u7684\u3002\u7236\u8fdb\u7a0b\u53ef\u4ee5\u9009\u62e9\u5ffd\u7565\u8fd9\u4e2a\u4fe1\u53f7\u6216\u8005\u63d0\u4f9b\u4e00\u4e2a\u88ab\u79f0\u4f5c\u201c\u4fe1\u53f7\u53e5\u67c4\u201d\u7684\u51fd\u6570\u6765\u5904\u7406\u3002\u9ed8\u8ba4\u5904\u7406\u65b9\u6cd5\u662f\u5ffd\u7565\u8be5\u4fe1\u53f7\u3002\u73b0\u5728\u804a\u8fd9\u4e2a\u8fd8\u6709\u70b9\u65e9\uff0c\u73b0\u5728\u53ea\u8981\u77e5\u9053<span style=\"color: #993300;\">wait<\/span>\u6216<span style=\"color: #993300;\">waitpid<\/span>\u53ef\u4ee5\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u5b83\u7684\u6240\u6709\u5b50\u8fdb\u7a0b\u90fd\u5728\u8fd0\u884c\uff0c\u90a3\u4e48\u4f1a\u963b\u585e\u3002<\/li>\n<li>\u5982\u679c\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u5df2\u7ecf\u7ed3\u675f\u5e76\u4e14\u6b63\u5728\u7b49\u5f85\u53cd\u9988\u81ea\u5df1\u7684\u7ec8\u6b62\u72b6\u6001\uff0c\u7acb\u5373\u8fd4\u56de\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u7684\u7ec8\u6b62\u72b6\u6001\u3002<\/li>\n<li>\u5982\u679c\u6ca1\u6709\u4efb\u4f55\u5b50\u8fdb\u7a0b\u5728\u8fd0\u884c\uff0c\u90a3\u4e48\u4f1a\u7acb\u5373\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\u3002<\/li>\n<\/ul>\n<p>\u5982\u679c\u8fdb\u7a0b\u8c03\u7528\u4e86<span style=\"color: #993300;\">wait<\/span>\u662f\u56e0\u4e3a\u5b83\u6536\u5230\u4e86<span style=\"color: #993300;\">SIGCHLE<\/span>\u4fe1\u53f7\u7684\u8bdd\uff0c\u6211\u4eec\u5e0c\u671b<span style=\"color: #993300;\">wait<\/span>\u53ef\u4ee5\u7acb\u5373\u8fd4\u56de\u3002\u4f46\u662f\u5982\u679c\u5728\u968f\u673a\u7684\u65f6\u95f4\u70b9\u8c03\u7528\u5b83\u7684\u8bdd\uff0c\u5b83\u4f1a\u4ea7\u751f\u963b\u585e\u3002<\/p>\n<table class=\"allBorders\" border=\"1\" rules=\"none\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<pre><span style=\"color: #993300;\">#include &lt;sys\/wait.h&gt;\r\n\r\npid_t wait(int *<span class=\"docEmphItalicAlt\">statloc<\/span>);\r\n\r\npid_t waitpid(pid_t <span class=\"docEmphItalicAlt\">pid<\/span>, int *<span class=\"docEmphItalicAlt\">statloc<\/span>, int <span class=\"docEmphItalicAlt\">options<\/span>);<\/span><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"right\" valign=\"top\">\n<p class=\"docText\">Both return: process ID if OK, 0 (see later), or 1 on error<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e24\u4e2a\u51fd\u6570\u7684\u4e0d\u540c\u662f\uff1a<\/p>\n<ul>\n<li><span style=\"color: #993300;\">wait<\/span>\u51fd\u6570\u53ef\u4ee5\u963b\u585e\u8c03\u7528\u8005\uff0c\u76f4\u5230\u5b50\u8fdb\u7a0b\u7ed3\u675f\u3002\u800c<span style=\"color: #993300;\">waitpid<\/span>\u6709\u4e00\u4e2a\u9632\u6b62\u8c03\u7528\u8005\u963b\u585e\u7684\u9009\u9879\u3002<\/li>\n<li><span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u5e76\u4e0d\u662f\u5148\u7b49\u5f85\u5b50\u8fdb\u7a0b\u7ed3\u675f\uff1b\u5b83\u6709\u5f88\u591a\u7684\u9009\u9879\u7528\u4e8e\u63a7\u5236\u54ea\u4e9b\u8fdb\u7a0b\u662f\u5b83\u8981\u7b49\u5f85\u7684\u3002<\/li>\n<\/ul>\n<p>\u5982\u679c\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u5df2\u7ecf\u7ec8\u6b62\u5e76\u4e14\u53d8\u6210\u4e86zombie\u8fdb\u7a0b\uff0c<span style=\"color: #993300;\">wait<\/span>\u4f1a\u7acb\u5373\u8fd4\u56de\u5b50\u8fdb\u7a0b\u7684\u72b6\u6001\u3002\u53e6\u5916\u5b83\u963b\u585e\u4e86\u8c03\u7528\u8005\u76f4\u5230\u5b50\u8fdb\u7a0b\u7ed3\u675f\u3002\u5982\u679c\u8c03\u7528\u8005\u6709\u591a\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u5f53\u5176\u4e2d\u4e00\u4e2a\u7ed3\u675f\u65f6<span style=\"color: #993300;\">wait<\/span>\u5c31\u4f1a\u8fd4\u56de\u3002\u56e0\u4e3a\u8fdb\u7a0bID\u88ab\u7a0b\u5e8f\u8fd4\u56de\uff0c\u6240\u4ee5\u53ef\u4ee5\u4e00\u76f4\u5f97\u77e5\u662f\u54ea\u4e2a\u5b50\u8fdb\u7a0b\u7ed3\u675f\u4e86\u3002<\/p>\n<p>\u8fd9\u4e24\u4e2a\u51fd\u6570\u7684<em>statloc<\/em>\u662f\u4e00\u4e2a\u6307\u5411\u6574\u6570\u7684\u6307\u9488\uff0c\u7528\u4e8e\u5b58\u50a8\u8fdb\u7a0b\u7684\u7ec8\u6b62\u72b6\u6001\u3002\u5982\u679c\u5e76\u4e0d\u5173\u5fc3\u7ec8\u6b62\u72b6\u6001\uff0c\u53ea\u8981\u4f20\u4e00\u4e2a\u7a7a\u6307\u9488\u7ed9\u8fd9\u4e2a\u53c2\u6570\u5c31\u53ef\u4ee5\u3002<\/p>\n<p>\u4f20\u7edf\u4e0a\uff0c\u8fd9\u4e24\u4e2a\u51fd\u6570\u8fd4\u56de\u7684\u6574\u6570\u72b6\u6001\u662f\u88ab\u5b9e\u73b0\u5b9a\u4e49\u7684\uff0c\u4e00\u4e9b\u4f4d\u6307\u793a\u4e86\u9000\u51fa\u72b6\u6001\uff08\u6b63\u5e38\u9000\u51fa\uff09\uff0c\u53e6\u4e00\u4e9b\u4f4d\u6307\u793a\u4e86\u4fe1\u53f7\u6570\uff08\u975e\u6b63\u5e38\u8fd4\u56de\uff09\uff0c\u6709\u4e00\u4f4d\u7528\u6765\u6307\u793a\u662f\u5426\u4ea7\u751f\u4e86core file\uff0c\u7b49\u7b49\u3002POSIX.1\u6307\u5b9a\u4e86\u7ec8\u6b62\u72b6\u6001\uff0c\u8fd9\u4e9b\u72b6\u6001\u4f7f\u7528\u5b9a\u4e49\u5728<span style=\"color: #993300;\">&lt;sys\/wait.h&gt;<\/span>\u4e2d\u7684\u5404\u79cd\u5b8f\u6765\u8fa8\u522b\u3002\u56db\u79cd\u4e92\u65a5\u7684\u5b8f\u544a\u8bc9\u6211\u4eec\u8fdb\u7a0b\u662f\u5982\u4f55\u7ec8\u6b62\u7684\uff0c\u5e76\u4e14\u5b83\u4eec\u90fd\u4ee5<span style=\"color: #993300;\">WIF<\/span>\u5f00\u5934\u3002\u57fa\u4e8e\u8fd9\u56db\u79cd\u5b8f\u54ea\u4e2a\u4e00\u4e3a\u771f\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u5176\u5b83\u4e00\u4e9b\u5b8f\u6765\u83b7\u5f97\u9000\u51fa\u72b6\u6001\u548c\u4fe1\u53f7\u91cf\u7b49\u7b49\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u8fd9\u56db\u79cd\u5b8f\uff1a<\/p>\n<h3>Figure 8.4 Macros to examine the termination status returned by <span style=\"color: #993300;\">wait<\/span> and <span style=\"color: #993300;\">waitpid<\/span><\/h3>\n<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<table class=\"allBorders\" border=\"1\" rules=\"all\" cellspacing=\"0\" cellpadding=\"4\">\n<thead>\n<tr>\n<th class=\"thead\" scope=\"col\" align=\"center\" valign=\"top\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Macro<\/span><\/p>\n<\/th>\n<th class=\"thead\" scope=\"col\" align=\"center\" valign=\"top\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Description<\/span><\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>WIFEXITED<\/tt>(<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\">True if status was returned for a child that terminated normally. In this case, we can execute<\/p>\n<blockquote>\n<p class=\"docList\"><tt>WEXITSTATUS<\/tt> (<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/blockquote>\n<p class=\"docText\">to fetch the low-order 8 bits of the argument that the child passed to <tt>exit<\/tt>, <tt>_exit<\/tt>,or <tt>_Exit<\/tt>.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>WIFSIGNALED<\/tt> (<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\">True if status was returned for a child that terminated abnormally, by receipt of a signal that it didn&#8217;t catch. In this case, we can execute<\/p>\n<blockquote>\n<p class=\"docList\"><tt>WTERMSIG<\/tt> (<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/blockquote>\n<p class=\"docText\">to fetch the signal number that caused the termination.<\/p>\n<p class=\"docText\">Additionally, some implementations (but not the Single UNIX Specification) define the macro<\/p>\n<blockquote>\n<p class=\"docList\"><tt>WCOREDUMP<\/tt> (<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/blockquote>\n<p class=\"docText\">that returns true if a core file of the terminated process was generated.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>WIFSTOPPED<\/tt> (<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\">True if status was returned for a child that is currently stopped. In this case, we can execute<\/p>\n<blockquote>\n<p class=\"docList\"><tt>WSTOPSIG<\/tt> (<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/blockquote>\n<p class=\"docText\">to fetch the signal number that caused the child to stop.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>WIFCONTINUED<\/tt> (<span class=\"docEmphasis\">status<\/span>)<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\">True if status was returned for a child that has been continued after a job control stop (XSI extension to POSIX.1; <tt>waitpid<\/tt> only).<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u6709\u5f88\u591a\u7684\u5b50\u8fdb\u7a0b\uff0c\u6211\u4eec\u53ea\u60f3\u5f97\u5230\u67d0\u4e2a\u7279\u5b9a\u7684\u5b50\u8fdb\u7a0b\u7684\u7ec8\u6b62\u72b6\u6001\uff0c\u5728\u4e00\u4e9b\u7248\u672c\u7684unix\u7cfb\u7edf\u4e2d\u7684\u505a\u6cd5\u662f\uff0c<span style=\"color: #993300;\">wait<\/span>\u6536\u5230\u4e00\u4e2a\u6d88\u606f\u540e\u5224\u65ad\u5b83\u7684PID\u662f\u4e0d\u662f\u6211\u4eec\u9700\u8981\u7684\uff0c\u5982\u679c\u4e0d\u662f\uff0c\u518d\u6b21\u8fd0\u884c<span style=\"color: #993300;\">wait<\/span>\uff08\u56e0\u4e3a<span style=\"color: #993300;\">wait<\/span>\u53ea\u8981\u4efb\u4f55\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u7ed3\u675f\uff0c\u5b83\u5c31\u4f1a\u8fd4\u56de\uff09\u3002\u4ece\u5b9e\u7528\u89d2\u5ea6\u51fa\u53d1\uff0cPOSIX.1\u5b9a\u4e49\u4e86<span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u3002<\/p>\n<p>\u5bf9\u4e8e<span style=\"color: #993300;\">waitpid<\/span>\u7684<em><span style=\"color: #000000;\">pid<\/span><\/em>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<p>pid==1\u00a0 \u7b49\u540c\u4e8e<span style=\"color: #993300;\">wait<\/span>\u51fd\u6570<\/p>\n<p>pid&gt;0\u00a0\u00a0\u00a0\u00a0 \u7b49\u5f85\u7279\u5b9a\u7684PID\u5b50\u8fdb\u7a0b\u3002<\/p>\n<p>pid==0\u00a0 \u7b49\u5f85\u5b50\u8fdb\u7a0b\u7684\u7ec4ID\u7b49\u540c\u4e8e\u8c03\u7528\u8fdb\u7a0b\u7684ID\uff08\u8fd9\u8bf4\u7684\u662f\u4e0d\u662f\u8c03\u7528<span style=\"color: #993300;\">waitpid<\/span>\u7684\u8fdb\u7a0b\uff1f\uff09\u3002<\/p>\n<p>pid&lt;1\u00a0\u00a0\u00a0\u00a0 \u7b49\u5f85\u5b50\u8fdb\u7a0b\u7684\u7ec4ID\u7b49\u4e8epid\u7684\u7edd\u5bf9\u503c\u3002<\/p>\n<p><span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u8fd4\u56de\u5b50\u8fdb\u7a0b\u7684ID\uff0c\u5b83\u7684\u7ec8\u6b62\u72b6\u6001\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\u88ab<em>statloc<\/em>\u6307\u9488\u7d22\u5f15\u3002<span style=\"color: #993300;\">wait<\/span>\u51fd\u6570\u552f\u4e00\u4f1a\u53d1\u751f\u7684\u5b9e\u9645\u9519\u8bef\u662f\uff0c\u8c03\u7528\u5b83\u7684\u8fdb\u7a0b\u6ca1\u6709\u5b50\u8fdb\u7a0b\uff08\u53e6\u4e00\u79cd\u53ef\u80fd\u662f\u51fd\u6570\u7684\u8c03\u7528\u88ab\u4fe1\u53f7\u4e2d\u65ad\uff09\u3002\u540c\u6837\u7684\u9519\u8bef\u4e5f\u53ef\u80fd\u53d1\u751f\u5728waitpid\u51fd\u6570\u4e0a\uff0c\u5982\uff0c\u6307\u5b9a\u7684\u8fdb\u7a0bID\u6216\u8fdb\u7a0b\u7ec4ID\u4e0d\u5b58\u5728\uff0c\u6216\u8005\u6ca1\u6709\u5b50\u8fdb\u7a0b\u3002<\/p>\n<p><em>option<\/em>\u53c2\u6570\u53ef\u4ee5\u8ba9<span style=\"color: #993300;\">waitpid<\/span>\u6709\u66f4\u591a\u7684\u63a7\u5236\u65b9\u5f0f\uff0c\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u662f0\u6216\u8005\u662f\u4e00\u4e9b\u5e38\u91cf\u505aOR\u8fd0\u7b97\uff0c\u53ef\u4ee5\u4f7f\u7528\u7684\u5e38\u91cf\u5982\u4e0b\uff1a<\/p>\n<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<table class=\"allBorders\" border=\"1\" rules=\"all\" cellspacing=\"0\" cellpadding=\"4\">\n<caption>\n<h5 class=\"docTableTitle\">Figure 8.7. The <span class=\"docEmphasis\">options<\/span> constants for <span style=\"color: #993300;\"><tt>waitpid<\/tt><\/span><\/h5>\n<\/caption>\n<colgroup>\n<col width=\"100\" \/>\n<col width=\"400\" \/><\/colgroup>\n<thead>\n<tr>\n<th class=\"thead\" scope=\"col\" align=\"center\" valign=\"top\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Constant<\/span><\/p>\n<\/th>\n<th class=\"thead\" scope=\"col\" align=\"center\" valign=\"top\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Description<\/span><\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>WCONTINUED<\/tt><\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\">\u5982\u679c\u5b9e\u73b0\u652f\u6301\u4efb\u52a1\u63a7\u5236\uff0c\u4efb\u4f55\u7531pid\u6307\u5b9a\u7684\u5b50\u8fdb\u7a0b\uff0c\u5b83\u5df2\u7ecf\u88ab\u505c\u6b62\uff0c\u4f46\u4ecd\u7136\u5728\u8fd0\u884c\uff0c\u800c\u4e14\u5b83\u7684\u72b6\u6001\u8fd8\u6ca1\u6709\u88ab\u62a5\u544a\uff0c\u90a3\u4e48\u8fd4\u56de\u5b83\u7684\u72b6\u6001\u3002\uff08XSI\u6269\u5c55\u5230POSIX.1\uff09\uff08\u7ffb\u8bd1\u7684\u5bf9\u4e48\uff1f\uff1f\uff09<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>WNOHANG<\/tt><\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\">\u5982\u679c\u7531pid\u6307\u5b9a\u7684\u5b50\u8fdb\u7a0b\u5f53\u524d\u4e0d\u53ef\u7528\uff0c<span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u5c06\u4e0d\u963b\u585e\u3002\u5728\u672c\u4f8b\u4e2d\u8fd4\u56de\u503c\u4e3a0\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>WUNTRACED<\/tt><\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<p class=\"docText\">\u5982\u679c\u5b9e\u73b0\u652f\u6301\u4efb\u52a1\u63a7\u5236\uff0c\u4efb\u4f55\u7531pid\u6307\u5b9a\u7684\u5df2\u7ecf\u505c\u6b62\u7684\u5b50\u8fdb\u7a0b\uff0c\u7531\u4e8e\u5b83\u5df2\u7ecf\u505c\u6b62\u6240\u6ca1\u62a5\u544a\u5b83\u7684\u72b6\u6001\uff0c\u90a3\u4e48\u8fd4\u56de\u5b83\u7684\u72b6\u6001\u3002<span style=\"color: #993300;\">WIFSTOPPED<\/span>\u5b8f\u5224\u65ad\u8fd4\u56de\u503c\u662f\u5426\u662f\u76f8\u5e94\u7684\u5df2\u7ecf\u505c\u6b62\u7684\u5b50\u8fdb\u7a0b\u3002<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u63d0\u4f9b\u4e09\u79cd\u529f\u80fd\uff0c\u4f46\u662f\u5e76\u4e0d\u63d0\u4f9b\u7ed9<span style=\"color: #993300;\">wait<\/span>\u51fd\u6570\u3002<\/p>\n<ol>\n<li><span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u8ba9\u6211\u4eec\u7b49\u5f85\u7279\u5b9a\u7684\u8fdb\u7a0b\uff0c\u800c<span style=\"color: #993300;\">wait<\/span>\u51fd\u6570\u8fd4\u56de\u4efb\u610f\u5df2\u7ec8\u6b62\u7684\u5b50\u8fdb\u7a0b\u7684\u72b6\u6001\u3002<\/li>\n<li><span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u963b\u585e\u7248\u672c<span style=\"color: #993300;\">wait<\/span>\u3002\u5f53\u6211\u4eec\u60f3\u5f97\u5230\u5b50\u8fdb\u7a0b\u7684\u72b6\u6001\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u60f3\u963b\u585e\u7a0b\u5e8f\u65f6\u3002<\/li>\n<li><span style=\"color: #993300;\">waitpid<\/span>\u51fd\u6570\u652f\u6301\u4efb\u52a1\u63a7\u5236\uff0c\u53ef\u4ee5\u4f7f\u7528<span style=\"color: #993300;\">WUNTRACED<\/span>\u548c<span style=\"color: #993300;\">WCONTINUED<\/span>\u9009\u9879\u3002<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65e0\u8bba\u8fdb\u7a0b\u662f\u6b63\u5e38\u7ed3\u675f\u8fd8\u662f\u975e\u6b63\u5e38\u7ed3\u675f\uff0c\u5185\u6838\u90fd\u4f1a\u53d1\u9001SIGCHLD\u4fe1\u53f7\u7ed9\u5b83\u7684\u7236\u8fdb\u7a0b\uff0c\u4ee5\u544a\u77e5\u5b50\u8fdb\u7a0b\u7ed3\u675f\u3002\u56e0\u4e3a\u5b50\u8fdb\u7a0b\u7ed3\u675f\u662f\u4e00\u4e2a\u5f02\u6b65\u4e8b\u4ef6\uff0c\u5b83\u53ef\u4ee5\u53d1\u751f\u5728\u4efb\u4f55\u7236\u8fdb\u7a0b\u8fd0\u884c\u7684\u65f6\u95f4\uff0c&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=395\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-395","post","type-post","status-publish","format-standard","hentry","category-apue"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=395"}],"version-history":[{"count":7,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":445,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions\/445"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}