<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pcntl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.pcntl-wait.php',
    1 => 'pcntl_wait',
    2 => '待つかフォークした子プロセスのステータスを返す',
  ),
  'up' => 
  array (
    0 => 'ref.pcntl.php',
    1 => 'PCNTL 関数',
  ),
  'prev' => 
  array (
    0 => 'function.pcntl-unshare.php',
    1 => 'pcntl_unshare',
  ),
  'next' => 
  array (
    0 => 'function.pcntl-waitid.php',
    1 => 'pcntl_waitid',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/pcntl/functions/pcntl-wait.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pcntl-wait" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pcntl_wait</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pcntl_wait</span> &mdash; <span class="dc-title">待つかフォークした子プロセスのステータスを返す</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"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter reference">&$status</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter reference">&$resource_usage</code><span class="initializer"> = []</span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   この関数は、子プロセスが終了する・
   カレントのプロセスを終了させるシグナルが送信される・シグナル処理関数を
   コールするシグナルが送信される
   のいずれかが発生するまでカレントのプロセスの実行を中断します。
   子プロセスが、 コール時に
   既に終了している場合(&quot;ゾンビ&quot;プロセスと呼ばれます)、この関数は
   直ちに処理を返します。子プロセスにより使用される全てのシステム
   リソースは、解放されます。waitpid のシステムでの動作に関する詳細は、
   システムの wait(2) についての man ページを参照ください。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    この関数は、<code class="parameter">process_id</code> に <code class="literal">-1</code>
    を指定し、<code class="parameter">flags</code> を何も設定せずに
    <span class="function"><a href="function.pcntl-waitpid.php" 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> の中にステータス情報を保存します。
       このステータスは、次の関数を用いて評価可能です。
       <span class="function"><a href="function.pcntl-wifexited.php" class="function">pcntl_wifexited()</a></span>、
       <span class="function"><a href="function.pcntl-wifstopped.php" class="function">pcntl_wifstopped()</a></span>、
       <span class="function"><a href="function.pcntl-wifsignaled.php" class="function">pcntl_wifsignaled()</a></span>、
       <span class="function"><a href="function.pcntl-wexitstatus.php" class="function">pcntl_wexitstatus()</a></span>、
       <span class="function"><a href="function.pcntl-wtermsig.php" class="function">pcntl_wtermsig()</a></span> および
       <span class="function"><a href="function.pcntl-wstopsig.php" class="function">pcntl_wstopsig()</a></span> 。
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       システム上で wait3 が使用可能な場合 (ほとんどの BSD 系システムが
       該当します)、オプションのパラメータ <code class="parameter">flags</code>
       を使用可能です。このパラメータが指定されない場合、wait はシステムコールに
       対して使用されます。wait3 が使用できない場合、<code class="parameter">flags
       </code> に値を設定しても何の影響も及ぼしません。
       <code class="parameter">flags</code> の値は、次の 2 つのグローバル定数の
       ゼロまたはそれ以上の論理和です。
       <table class="doctable table">
        <caption><strong><code class="parameter">flags</code> のとりうる値</strong></caption>
        
         <tbody class="tbody">
          <tr>
           <td><strong><code><a href="pcntl.constants.php#constant.wnohang">WNOHANG</a></code></strong></td>
           <td>
            子プロセスが終了していない場合に直ちに処理を返します。
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="pcntl.constants.php#constant.wuntraced">WUNTRACED</a></code></strong></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> は、終了した子プロセスの
   プロセス ID を返します。エラーの場合は -1、(wait3 が使用可能なシステムで)
   WNOHANG が使用され、子プロセスが利用できない場合に 0 を返します。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pcntl-wait-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pcntl-fork.php" class="function" rel="rdfs-seeAlso">pcntl_fork()</a> - 現在実行中のプロセスをフォークする</span></li>
    <li><span class="function"><a href="function.pcntl-signal.php" class="function" rel="rdfs-seeAlso">pcntl_signal()</a> - シグナルハンドラを設定する</span></li>
    <li><span class="function"><a href="function.pcntl-wifexited.php" class="function" rel="rdfs-seeAlso">pcntl_wifexited()</a> - ステータスコードが正常終了を表しているかどうかを調べる</span></li>
    <li><span class="function"><a href="function.pcntl-wifstopped.php" class="function" rel="rdfs-seeAlso">pcntl_wifstopped()</a> - 子プロセスが現在停止しているかどうかを調べる</span></li>
    <li><span class="function"><a href="function.pcntl-wifsignaled.php" class="function" rel="rdfs-seeAlso">pcntl_wifsignaled()</a> - ステータスコードがシグナルによる終了を表しているかどうかを調べる</span></li>
    <li><span class="function"><a href="function.pcntl-wexitstatus.php" class="function" rel="rdfs-seeAlso">pcntl_wexitstatus()</a> - 終了した子プロセスのリターンコードを返す</span></li>
    <li><span class="function"><a href="function.pcntl-wtermsig.php" class="function" rel="rdfs-seeAlso">pcntl_wtermsig()</a> - 子プロセスを終了させたシグナルを返す</span></li>
    <li><span class="function"><a href="function.pcntl-wstopsig.php" class="function" rel="rdfs-seeAlso">pcntl_wstopsig()</a> - 子プロセスを停止させたシグナルを返す</span></li>
    <li><span class="function"><a href="function.pcntl-waitpid.php" class="function" rel="rdfs-seeAlso">pcntl_waitpid()</a> - 待つかフォークした子プロセスのステータスを返す</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>