<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.pcntl-waitpid.php',
    1 => 'pcntl_waitpid',
    2 => 'Waits on or returns the status of a forked child',
  ),
  'up' => 
  array (
    0 => 'ref.pcntl.php',
    1 => 'PCNTL Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.pcntl-waitid.php',
    1 => 'pcntl_waitid',
  ),
  'next' => 
  array (
    0 => 'function.pcntl-wexitstatus.php',
    1 => 'pcntl_wexitstatus',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pcntl/functions/pcntl-waitpid.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pcntl-waitpid" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pcntl_waitpid</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pcntl_waitpid</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-waitpid-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pcntl_waitpid</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$process_id</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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><br>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Suspends execution of the current process until a child as specified by
   the <code class="parameter">process_id</code> 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 <code class="parameter">process_id</code> 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 waitpid(2) man page for specific details as to
   how waitpid works on your system.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pcntl-waitpid-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">process_id</code></dt>
     <dd>
      <p class="para">
       The value of <code class="parameter">process_id</code> can be one of the following:
       <table class="doctable table">
        <caption><strong>possible values for <code class="parameter">process_id</code></strong></caption>
        
         <tbody class="tbody">
          <tr>
           <td><code class="literal">&lt; -1</code></td>
           <td>
            wait for any child process whose process group ID is equal to
            the absolute value of <code class="parameter">process_id</code>.
           </td>
          </tr>

          <tr>
           <td><code class="literal">-1</code></td>
           <td>
            wait for any child process; this is the same behaviour that
            the <span class="function"><a href="function.pcntl-wait.php" class="function">pcntl_wait()</a></span> function exhibits.
           </td>
          </tr>

          <tr>
           <td><code class="literal">0</code></td>
           <td>
            wait for any child process whose process group ID is equal to
            that of the calling process.
           </td>
          </tr>

          <tr>
           <td><code class="literal">&gt; 0</code></td>
           <td>
            wait for the child whose process ID is equal to the value of
            <code class="parameter">process_id</code>.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <p class="para">
        Specifying <code class="literal">-1</code> as the <code class="parameter">process_id</code> is
        equivalent to the functionality <span class="function"><a href="function.pcntl-wait.php" class="function">pcntl_wait()</a></span> provides
        (minus <code class="parameter">flags</code>).
       </p>
      </p></blockquote>
     </dd>
    
    
     <dt><code class="parameter">status</code></dt>
     <dd>
      <p class="para">
       <span class="function"><strong>pcntl_waitpid()</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">
       The value of <code class="parameter">flags</code> is the value of zero
       or more of the following two global 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-waitpid-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   <span class="function"><strong>pcntl_waitpid()</strong></span> returns the process ID of the
   child which exited, -1 on error or zero if <strong><code><a href="pcntl.constants.php#constant.wnohang">WNOHANG</a></code></strong> was used and no
   child was available
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pcntl-waitpid-seealso">
  <h3 class="title">Vedere anche:</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>
   </ul>
  </p>
 </div>


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