<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.pcntl-wait.php',
    1 => 'pcntl_wait',
    2 => 'Waits on or returns the status of a forked child',
  ),
  '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' => 'en',
    '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">Waits on or returns the status of a forked child</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">
   The wait function suspends execution of the current process until a
   child has exited, or until a signal is delivered whose action is to
   terminate the current process or to call a signal handling function.  If a
   child has already exited by the time of the call (a so-called &quot;zombie&quot;
   process), the function returns immediately.  Any system resources used by
   the child are freed.  Please see your system&#039;s wait(2) man page for
   specific details as to how wait works on your system.
  </p>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    This function is equivalent to calling <span class="function"><a href="function.pcntl-waitpid.php" class="function">pcntl_waitpid()</a></span>
    with a <code class="literal">-1</code> <code class="parameter">process_id</code> and no
    <code class="parameter">flags</code>.
   </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> will store status information
       in the <code class="parameter">status</code> parameter which can be
       evaluated using the following functions:
       <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> and
       <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">
       If wait3 is available on your system (mostly BSD-style systems), you can
       provide the optional <code class="parameter">flags</code> parameter.  If this
       parameter is not provided, wait will be used for the system call.  If
       wait3 is not available, providing a value for <code class="parameter">flags</code>
       will have no effect. The value of <code class="parameter">flags</code>
       is the value of zero or more of the following two constants
       <code class="literal">OR</code>&#039;ed together:
       <table class="doctable table">
        <caption><strong>Possible values for <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>
            Return immediately if no child has exited.
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="pcntl.constants.php#constant.wuntraced">WUNTRACED</a></code></strong></td>
           <td>
            Return for children which are stopped, and whose status has
            not been reported.
           </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> returns the process ID of the
   child which exited, -1 on error or zero if WNOHANG was provided as an
   option (on wait3-available systems) and no child was available.
  </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> - Forks the currently running process</span></li>
    <li><span class="function"><a href="function.pcntl-signal.php" class="function" rel="rdfs-seeAlso">pcntl_signal()</a> - Installs a signal handler</span></li>
    <li><span class="function"><a href="function.pcntl-wifexited.php" class="function" rel="rdfs-seeAlso">pcntl_wifexited()</a> - Checks if status code represents a normal exit</span></li>
    <li><span class="function"><a href="function.pcntl-wifstopped.php" class="function" rel="rdfs-seeAlso">pcntl_wifstopped()</a> - Checks whether the child process is currently stopped</span></li>
    <li><span class="function"><a href="function.pcntl-wifsignaled.php" class="function" rel="rdfs-seeAlso">pcntl_wifsignaled()</a> - Checks whether the status code represents a termination due to a signal</span></li>
    <li><span class="function"><a href="function.pcntl-wexitstatus.php" class="function" rel="rdfs-seeAlso">pcntl_wexitstatus()</a> - Returns the return code of a terminated child</span></li>
    <li><span class="function"><a href="function.pcntl-wtermsig.php" class="function" rel="rdfs-seeAlso">pcntl_wtermsig()</a> - Returns the signal which caused the child to terminate</span></li>
    <li><span class="function"><a href="function.pcntl-wstopsig.php" class="function" rel="rdfs-seeAlso">pcntl_wstopsig()</a> - Returns the signal which caused the child to stop</span></li>
    <li><span class="function"><a href="function.pcntl-waitpid.php" class="function" rel="rdfs-seeAlso">pcntl_waitpid()</a> - Waits on or returns the status of a forked child</span></li>
   </ul>
  </p>
 </div>


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