uTools-Manuals/docs/php/pcntl_wait.html
2019-04-08 23:22:26 +08:00

134 lines
6.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>等待或返回fork的子进程状态</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.pcntl-wait" class="refentry">
<div class="refnamediv">
<h1 class="refname">pcntl_wait</h1>
<p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">pcntl_wait</span> &mdash; <span class="dc-title">等待或返回fork的子进程状态</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.pcntl-wait-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>pcntl_wait</strong></span>
( <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$status</code></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>
] ) : <span class="type">int</span></div>
<p class="para rdfs-comment">
wait函数刮起当前进程的执行直到一个子进程退出或接收到一个信号要求中断当前进程或调用一个信号处理函数。
如果一个子进程在调用此函数时已经退出(俗称僵尸进程),此函数立刻返回。子进程使用的所有系统资源将
被释放。关于wait在您系统上工作的详细规范请查看您系统的wait2手册。
</p>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
这个函数等同于以<em>-1</em>作为参数<code class="parameter">pid</code>
的值并且没有<code class="parameter">options</code>参数来调用<span class="function"><a href="pcntl_waitpid.html" class="function">pcntl_waitpid()</a></span>
函数。
</p>
</p></blockquote>
</div>
<div class="refsect1 parameters" id="refsect1-function.pcntl-wait-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">status</code></dt>
<dd>
<p class="para">
<span class="function"><strong>pcntl_wait()</strong></span>将会存储状态信息到<code class="parameter">status</code>
参数上,这个通过<code class="parameter">status</code>参数返回的状态信息可以用以下函数
<span class="function"><a href="pcntl_wifexited.html" class="function">pcntl_wifexited()</a></span>,
<span class="function"><a href="pcntl_wifstopped.html" class="function">pcntl_wifstopped()</a></span>,
<span class="function"><a href="pcntl_wifsignaled.html" class="function">pcntl_wifsignaled()</a></span>,
<span class="function"><a href="pcntl_wexitstatus.html" class="function">pcntl_wexitstatus()</a></span>,
<span class="function"><a href="pcntl_wtermsig.html" class="function">pcntl_wtermsig()</a></span>以及
<span class="function"><a href="pcntl_wstopsig.html" class="function">pcntl_wstopsig()</a></span>获取其具体的值。
</p>
</dd>
<dt>
<code class="parameter">options</code></dt>
<dd>
<p class="para">
如果您的操作系统多数BSD类系统允许使用wait3您可以提供可选的<code class="parameter">options</code>
参数。如果这个参数没有提供wait将会被用作系统调用。如果wait3不可用提供参数
<code class="parameter">options</code>不会有任何效果。<code class="parameter">options</code>的值可以是0
或者以下两个常量或两个常量“或运算”结果(即两个常量代表意义都有效)。
<table class="doctable table">
<caption><strong><code class="parameter">options</code>可用值</strong></caption>
<tbody class="tbody">
<tr>
<td><em>WNOHANG</em></td>
<td>
如果没有子进程退出立刻返回。
</td>
</tr>
<tr>
<td><em>WUNTRACED</em></td>
<td>
子进程已经退出并且其状态未报告时返回。
</td>
</tr>
</tbody>
</table>
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.pcntl-wait-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
<span class="function"><strong>pcntl_wait()</strong></span>返回退出的子进程进程号,发生错误时返回-1,如果提供了
<strong><code>WNOHANG</code></strong>作为optionwait3可用的系统并且没有可用子进程时返回0。
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.pcntl-wait-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="pcntl_fork.html" class="function" rel="rdfs-seeAlso">pcntl_fork()</a> - 在当前进程当前位置产生分支子进程。译注fork是创建了一个子进程父进程和子进程
都从fork的位置开始向下继续执行不同的是父进程执行过程中得到的fork返回值为子进程
而子进程得到的是0。</span></li>
<li class="member"><span class="function"><a href="pcntl_signal.html" class="function" rel="rdfs-seeAlso">pcntl_signal()</a> - 安装一个信号处理器</span></li>
<li class="member"><span class="function"><a href="pcntl_wifexited.html" class="function" rel="rdfs-seeAlso">pcntl_wifexited()</a> - 检查状态代码是否代表一个正常的退出。</span></li>
<li class="member"><span class="function"><a href="pcntl_wifstopped.html" class="function" rel="rdfs-seeAlso">pcntl_wifstopped()</a> - 检查子进程当前是否已经停止</span></li>
<li class="member"><span class="function"><a href="pcntl_wifsignaled.html" class="function" rel="rdfs-seeAlso">pcntl_wifsignaled()</a> - 检查子进程状态码是否代表由于某个信号而中断</span></li>
<li class="member"><span class="function"><a href="pcntl_wexitstatus.html" class="function" rel="rdfs-seeAlso">pcntl_wexitstatus()</a> - 返回一个中断的子进程的返回代码</span></li>
<li class="member"><span class="function"><a href="pcntl_wtermsig.html" class="function" rel="rdfs-seeAlso">pcntl_wtermsig()</a> - 返回导致子进程中断的信号</span></li>
<li class="member"><span class="function"><a href="pcntl_wstopsig.html" class="function" rel="rdfs-seeAlso">pcntl_wstopsig()</a> - 返回导致子进程停止的信号</span></li>
<li class="member"><span class="function"><a href="pcntl_waitpid.html" class="function" rel="rdfs-seeAlso">pcntl_waitpid()</a> - 等待或返回fork的子进程状态</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>