Go to the previous, next section.

wait4

SYNOPSIS

pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);

PARAMETERS

pid: [in] the pid of the child.

status: [out] the return status of the child.

options: [in] options for the wait.

rusage: [out] the ressource usage of the dead child.

DESCRIPTION

This call puts the calling task to sleep until the child specified by pid exits or a signal is caught. If a child that fits the request is already in a zombie state at the time of the call, the zombie is exorcised and the call retrurns immediately.

pid has different meanings according to the ranges of values it may take:

<-1
waits for the exit of any child with a process group id of -pid.

-1
wait for any child to exit.

0
wait for the exit of any child with a process group id equal to the one of the current task.

>0
wait for the child with pid equals to pid to exit.

If status is not NULL, then the return status of the child is stored to the area pointed to by status.

options is one or more of the following values or'ed together:

WNOHANG
do not wait for a process to exit.

WUNTRACED
also return for children who are stopped.

RETURN VALUE

The pid of the child who exited. If WNOHANG has been specified, then the call may return zero. In case of error, the call returns zero and errno is set to one of the following values:

Go to the previous, next section.