WAITPID(2)

NAME
waitpid - wait for a given pid

SYNOPSIS
#include <unistd.h>
int waitpid (pid_t pid, unsigned long *stat_addr, int options);

DESCRIPTION
waitpid() waits for pid as specified in options.

Alowable options are:
WUNTRACED - set when we want to be notified of successful exit of pid
WNOHANG - set if we don't want to wait around for a long time.

waitpid() will exit when :
1.  The waited for process terminates or enters a ZOMBIE state.
2.  An unblocked signal, or SIGCHLD is caught.
3.  An error condition occurs.

stat_addr is non NULL, then unless WUNTRACED is set and the status of pid is not TASKSTOPPED then *stat_addr will be set to the exit code of pid.

waitpid() will return one of the following :
1.  pid if the process terminates.
2.  0 if we told it to not hang, and the process hasn't terminated.
3.  A negative value indicating an error.

ERRORS
-ERESTARTSYS is returned if WNOHANG was not set, when an unblocked signal or SGICHLD was caught.

-ECHILD is returned if the child process didn't exist, or WUNTRACED was unclear and there was no exit code.

FILES
linux/kernel/signal.c
/usr/include/linux/sys.h
/usr/include/unistd.h

SEE ALSO
wait(3)