📄 function.pcntl-waitpid.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Waits on or returns the status of a forked child</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pcntl-wait.html">pcntl_wait</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pcntl-wexitstatus.html">pcntl_wexitstatus</a></div> <div class="up"><a href="ref.pcntl.html">PCNTL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.pcntl-waitpid" class="refentry"> <div class="refnamediv"> <h1 class="refname">pcntl_waitpid</h1> <p class="verinfo">(PHP 4 >= 4.0.7, PHP 5)</p><p class="refpurpose"><span class="refname">pcntl_waitpid</span> — <span class="dc-title">Waits on or returns the status of a forked child</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><b><b>pcntl_waitpid</b></b></span> ( <span class="methodparam"><span class="type">int</span> <tt class="parameter">$pid</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&$status</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$options</tt></span> ] )</div> <p class="para rdfs-comment"> Suspends execution of the current process until a child as specified by the <i><tt class="parameter">pid</tt></i> argument has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function. </p> <p class="para"> If a child as requested by <i><tt class="parameter">pid</tt></i> has already exited by the time of the call (a so-called "zombie" process), the function returns immediately. Any system resources used by the child are freed. Please see your system's waitpid(2) man page for specific details as to how waitpid works on your system. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">pid</tt></i></span> <dd> <p class="para"> The value of <i><tt class="parameter">pid</tt></i> can be one of the following: <table border="5"> <caption><b>possible values for <i><tt class="parameter">pid</tt></i></b></caption> <colgroup> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>< -1</i></td> <td colspan="1" rowspan="1" align="left"> wait for any child process whose process group ID is equal to the absolute value of <i><tt class="parameter">pid</tt></i>. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>-1</i></td> <td colspan="1" rowspan="1" align="left"> wait for any child process; this is the same behaviour that the wait function exhibits. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>0</i></td> <td colspan="1" rowspan="1" align="left"> wait for any child process whose process group ID is equal to that of the calling process. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>> 0</i></td> <td colspan="1" rowspan="1" align="left"> wait for the child whose process ID is equal to the value of <i><tt class="parameter">pid</tt></i>. </td> </tr> </tbody> </colgroup> </table> </p> <blockquote><p><b class="note">Note</b>: Specifying <i>-1</i> as the <i><tt class="parameter">pid</tt></i> is equivalent to the functionality <a href="function.pcntl-wait.html" class="function">pcntl_wait()</a> provides (minus <i><tt class="parameter">options</tt></i>). <br /> </p></blockquote> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">status</tt></i></span> <dd> <p class="para"> <b>pcntl_waitpid()</b> will store status information in the <i><tt class="parameter">status</tt></i> parameter which can be evaluated using the following functions: <a href="function.pcntl-wifexited.html" class="function">pcntl_wifexited()</a>, <a href="function.pcntl-wifstopped.html" class="function">pcntl_wifstopped()</a>, <a href="function.pcntl-wifsignaled.html" class="function">pcntl_wifsignaled()</a>, <a href="function.pcntl-wexitstatus.html" class="function">pcntl_wexitstatus()</a>, <a href="function.pcntl-wtermsig.html" class="function">pcntl_wtermsig()</a> and <a href="function.pcntl-wstopsig.html" class="function">pcntl_wstopsig()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">options</tt></i></span> <dd> <p class="para"> The value of <i><tt class="parameter">options</tt></i> is the value of zero or more of the following two global constants <i>OR</i>'ed together: <table border="5"> <caption><b>possible values for <i><tt class="parameter">options</tt></i></b></caption> <colgroup> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>WNOHANG</i></td> <td colspan="1" rowspan="1" align="left"> return immediately if no child has exited. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><i>WUNTRACED</i></td> <td colspan="1" rowspan="1" align="left"> return for children which are stopped, and whose status has not been reported. </td> </tr> </tbody> </colgroup> </table> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <b>pcntl_waitpid()</b> returns the process ID of the child which exited, -1 on error or zero if WNOHANG was used and no child was available </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.pcntl-fork.html" class="function" rel="rdfs-seeAlso">pcntl_fork()</a></li> <li class="member"><a href="function.pcntl-signal.html" class="function" rel="rdfs-seeAlso">pcntl_signal()</a></li> <li class="member"><a href="function.pcntl-wifexited.html" class="function" rel="rdfs-seeAlso">pcntl_wifexited()</a></li> <li class="member"><a href="function.pcntl-wifstopped.html" class="function" rel="rdfs-seeAlso">pcntl_wifstopped()</a></li> <li class="member"><a href="function.pcntl-wifsignaled.html" class="function" rel="rdfs-seeAlso">pcntl_wifsignaled()</a></li> <li class="member"><a href="function.pcntl-wexitstatus.html" class="function" rel="rdfs-seeAlso">pcntl_wexitstatus()</a></li> <li class="member"><a href="function.pcntl-wtermsig.html" class="function" rel="rdfs-seeAlso">pcntl_wtermsig()</a></li> <li class="member"><a href="function.pcntl-wstopsig.html" class="function" rel="rdfs-seeAlso">pcntl_wstopsig()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pcntl-wait.html">pcntl_wait</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pcntl-wexitstatus.html">pcntl_wexitstatus</a></div> <div class="up"><a href="ref.pcntl.html">PCNTL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -