downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.pcntl-wait.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.pcntl-wait.php',
   
1 => 'pcntl_wait',
  ),
 
'up' =>
  array (
   
0 => 'ref.pcntl.php',
   
1 => 'PCNTL Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.pcntl-sigwaitinfo.php',
   
1 => 'pcntl_sigwaitinfo',
  ),
 
'next' =>
  array (
   
0 => 'function.pcntl-waitpid.php',
   
1 => 'pcntl_waitpid',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.pcntl-wait" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pcntl_wait</h1>
  <p class="verinfo">(PHP 5)</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>
 
 <a name="function.pcntl-wait.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><b>pcntl_wait</b></span>
    ( <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&amp;$status</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$options</tt><span class="initializer"> = 0</span></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><p><b class="note">Note</b>:
  
    This function is equivalent to calling <a href="function.pcntl-waitpid.php" class="function">pcntl_waitpid()</a>
    with a <i>-1</i> <i><tt class="parameter">pid</tt></i>
 and no
    <i><tt class="parameter">options</tt></i>
.
   <br />
  </p></blockquote>
 </div>


 <a name="function.pcntl-wait.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">status</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       <b>pcntl_wait()</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.php" class="function">pcntl_wifexited()</a>,
       <a href="function.pcntl-wifstopped.php" class="function">pcntl_wifstopped()</a>,
       <a href="function.pcntl-wifsignaled.php" class="function">pcntl_wifsignaled()</a>,
       <a href="function.pcntl-wexitstatus.php" class="function">pcntl_wexitstatus()</a>,
       <a href="function.pcntl-wtermsig.php" class="function">pcntl_wtermsig()</a> and
       <a href="function.pcntl-wstopsig.php" class="function">pcntl_wstopsig()</a>.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">options</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       If wait3 is available on your system (mostly BSD-style systems), you can
       provide the optional <i><tt class="parameter">options</tt></i>
 parameter.  If this
       parameter is not provided, wait will be used for the system call.  If
       wait3 is not available, providing a value for <i><tt class="parameter">options
       </tt></i>
 will have no effect. The value of <i><tt class="parameter">options
       </tt></i>
 is the value of zero or more of the following two constants
       <i>OR</i>&#039;ed together:
       </p><table class="doctable table">
        <caption><b>Possible values for <i><tt class="parameter">options</tt></i>
</b></caption>
       
         <tbody valign="middle" class="tbody">
          <tr valign="middle">
           <td align="left"><i>WNOHANG</i></td>
           <td align="left">
            Return immediately if no child has exited.
           </td>
          </tr>

          <tr valign="middle">
           <td align="left"><i>WUNTRACED</i></td>
           <td align="left">
            Return for children which are stopped, and whose status has
            not been reported.
           </td>
          </tr>

         </tbody>
       
       </table>
<p>
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.pcntl-wait.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   <b>pcntl_wait()</b> 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>


 <a name="function.pcntl-wait.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.pcntl-fork.php" class="function" rel="rdfs-seeAlso">pcntl_fork()</a> - Forks the currently running process</li>
    <li class="member"><a href="function.pcntl-signal.php" class="function" rel="rdfs-seeAlso">pcntl_signal()</a> - Installs a signal handler</li>
    <li class="member"><a href="function.pcntl-wifexited.php" class="function" rel="rdfs-seeAlso">pcntl_wifexited()</a> - Checks if status code represents a normal exit</li>
    <li class="member"><a href="function.pcntl-wifstopped.php" class="function" rel="rdfs-seeAlso">pcntl_wifstopped()</a> - Checks whether the child process is currently stopped</li>
    <li class="member"><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</li>
    <li class="member"><a href="function.pcntl-wexitstatus.php" class="function" rel="rdfs-seeAlso">pcntl_wexitstatus()</a> - Returns the return code of a terminated child</li>
    <li class="member"><a href="function.pcntl-wtermsig.php" class="function" rel="rdfs-seeAlso">pcntl_wtermsig()</a> - Returns the signal which caused the child to terminate</li>
    <li class="member"><a href="function.pcntl-wstopsig.php" class="function" rel="rdfs-seeAlso">pcntl_wstopsig()</a> - Returns the signal which caused the child to stop</li>
    <li class="member"><a href="function.pcntl-waitpid.php" class="function" rel="rdfs-seeAlso">pcntl_waitpid()</a> - Waits on or returns the status of a forked child</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites