<HTML ><HEAD ><TITLE >pcntl_waitpid</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html"><LINK REL="UP" TITLE="Process Control Functions" HREF="ref.pcntl.html"><LINK REL="PREVIOUS" TITLE="pcntl_signal" HREF="function.pcntl-signal.html"><LINK REL="NEXT" TITLE="pcntl_wexitstatus" HREF="function.pcntl-wexitstatus.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual de PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.pcntl-signal.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.pcntl-wexitstatus.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.pcntl-waitpid" ></A >pcntl_waitpid</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN65353" ></A ><P > (PHP 4 >= 4.1.0)</P >pcntl_waitpid -- Waits on or returns the status of a forked child</DIV ><DIV CLASS="refsect1" ><A NAME="AEN65356" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >pcntl_waitpid</B > ( int pid, int status, int options)<BR ></BR ><P > The <B CLASS="function" >pcntl_waitpid()</B > function suspends execution of the current process until a child as specified by the <TT CLASS="parameter" ><I >pid</I ></TT > argument 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 as requested by <TT CLASS="parameter" ><I >pid</I ></TT > has already exited by the time of the call (a so-called "zombie" process), the function returns immediately. Any system resources used by the child are freed. Please see your system's waitpid(2) man page for specific details as to how waitpid works on your system. </P ><P > <B CLASS="function" >pcntl_waitpid()</B > returns the process ID of the child which exited, -1 on error or zero if WNOHANG was used and no child was available </P ><P > The value of <TT CLASS="parameter" ><I >pid</I ></TT > can be one of the following: <DIV CLASS="table" ><A NAME="AEN65378" ></A ><P ><B >Tabla 1. possible values for <TT CLASS="parameter" ><I >pid</I ></TT ></B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >< -1</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > wait for any child process whose process group ID is equal to the absolute value of <TT CLASS="parameter" ><I >pid</I ></TT >. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >-1</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > wait for any child process; this is the same behaviour that the wait function exhibits. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >0</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > wait for any child process whose process group ID is equal to that of the calling process. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >> 0</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > wait for the child whose process ID is equal to the value of <TT CLASS="parameter" ><I >pid</I ></TT >. </TD ></TR ></TBODY ></TABLE ></DIV > </P ><P > <B CLASS="function" >pcntl_waitpid()</B > will store status information in the <TT CLASS="parameter" ><I >status</I ></TT > parameter which can be evaluated using the following functions: <A HREF="function.pcntl-wifexited.html" ><B CLASS="function" >pcntl_wifexited()</B ></A >, <A HREF="function.pcntl-wifstopped.html" ><B CLASS="function" >pcntl_wifstopped()</B ></A >, <A HREF="function.pcntl-wifsignaled.html" ><B CLASS="function" >pcntl_wifsignaled()</B ></A >, <A HREF="function.pcntl-wexitstatus.html" ><B CLASS="function" >pcntl_wexitstatus()</B ></A >, <A HREF="function.pcntl-wtermsig.html" ><B CLASS="function" >pcntl_wtermsig()</B ></A > and <A HREF="function.pcntl-wstopsig.html" ><B CLASS="function" >pcntl_wstopsig()</B ></A >. </P ><P > The value of <TT CLASS="parameter" ><I >options</I ></TT > is the value of zero or more of the following two global constants <TT CLASS="literal" >OR</TT >'ed together: <DIV CLASS="table" ><A NAME="AEN65413" ></A ><P ><B >Tabla 2. possible values for <TT CLASS="parameter" ><I >options</I ></TT ></B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >WNOHANG</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > return immediately if no child has exited. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >WUNTRACED</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > return for children which are stopped, and whose status has not been reported. </TD ></TR ></TBODY ></TABLE ></DIV > </P ><P > See also <A HREF="function.pcntl-fork.html" ><B CLASS="function" >pcntl_fork()</B ></A >, <A HREF="function.pcntl-signal.html" ><B CLASS="function" >pcntl_signal()</B ></A >, <A HREF="function.pcntl-wifexited.html" ><B CLASS="function" >pcntl_wifexited()</B ></A >, <A HREF="function.pcntl-wifstopped.html" ><B CLASS="function" >pcntl_wifstopped()</B ></A >, <A HREF="function.pcntl-wifsignaled.html" ><B CLASS="function" >pcntl_wifsignaled()</B ></A >, <A HREF="function.pcntl-wexitstatus.html" ><B CLASS="function" >pcntl_wexitstatus()</B ></A >, <A HREF="function.pcntl-wtermsig.html" ><B CLASS="function" >pcntl_wtermsig()</B ></A > and <A HREF="function.pcntl-wstopsig.html" ><B CLASS="function" >pcntl_wstopsig()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.pcntl-signal.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.pcntl-wexitstatus.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >pcntl_signal</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.pcntl.html" ACCESSKEY="U" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >pcntl_wexitstatus</TD ></TR ></TABLE ></DIV ></BODY ></HTML >