The parent has several options for waiting for a child.
#include <sys/types.h>
#include <sys/wait.h>
pid_t waitpid(pid_t pid, int *status, int options);
- pid
- pid > 0 means wait for child with that pid to finish. The process group is that one child.
- pid = -1 means wait for any child of this process to finish. The process group is the set of all this process's children.
- status - This parameter should be the address of an integer
that will be assigned a value with some bits indicating the way the
child terminated or stopped and other bits that can contain the
exit or return value (an integer) of the child.
If NULL is passed, then waitpid just ignores this parameter.
- options - 0 or one of these constants defined in sys/wait.h
- WNOHANG
- WUNTRACED
- WNOHANG | WUNTRACED