perlfunc
gods
<P>
waitpid - wait for a particular child process to die
<P>
<HR>
<P>
waitpid
<FONT SIZE=-1>PID,FLAGS</FONT>
<P>
<HR>
<P>
Waits for a particular child process to terminate and returns the pid of
the deceased process, or <CODE>-1</CODE> if there is no such child process. The status is returned in <CODE>$?</CODE>. If you say
<P>
<PRE> use POSIX ":sys_wait_h";
#...
waitpid(-1,&WNOHANG);
</PRE>
<P>
then you can do a non-blocking wait for any process. Non-blocking wait is available on machines supporting either the
<CODE>waitpid(2)</CODE> or
<CODE>wait4(2)</CODE> system calls. However, waiting for a particular pid with
<FONT SIZE=-1>FLAGS</FONT> of
<CODE>0</CODE> is implemented everywhere. (Perl emulates the system call by remembering
the status values of processes that have exited but have not been harvested
by the Perl script yet.)
<P>
See [perlman:perlipc|the perlipc manpage] for other examples.
<HR>