COHERENT manpages

This page displays the COHERENT manpage for waitpid() [Wait for a process to terminate].

List of available manpages
Index


waitpid() -- System Call (libc)

Wait for a process to terminate
#include <sys/types.h>
#include <sys/wait.h>
pid_t waitpid(pid,status, flags)
pid_t pid; int *status, flags;

waitpid() waits until a given process terminates.  pid identifies the child
process whose  termination is awaited.  The value of  pid sets the behavior
of waitpid(), as follows:

pid>0
     Wait for the termination of the child process whose identifier is pid.

pid=0
     Wait for the termination of any child in the current process group.

pid=-1
     Wait  for  the  termination  of  any  child process.   In  this  mode,
     waitpid() behaves the same as the system call wait().

pid<-1
     Wait for termination of any child in the group given by -pid.

status  points  to  the  place  where  you  want  waitpid()  to  write  the
termination status of pid.

flags is the logical OR of the following values:

WNOHANG
     If  pid has  already  terminated, write  its  termination status  into
     status; but  if pid has not  yet terminated, do not wait  for it to do
     so.

WUNTRACED
     Report the status  of every child process of pid  that is stopped, and
     whose status has not been returned since it stopped.

By default,  waitpid() returns the  process identifier of  the chid process
whose status  is being reported, or  -1 if something went  wrong.  If flags
includes  WNOHANG,  waitpid()  returns zero  if  no  status information  is
available.

See Also

libc,
wait(),
wait.h
POSIX Standard, §3.2.1