Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/wait.h>
int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
The waitid() function suspends the calling process until one of its children changes state. It records the current state of a child in the structure pointed to by infop. If a child process changed state before the call, waitid() returns immediately.
The idtype and id arguments are used to specify which children waitid() will wait for.
If idtype is P_PID waitid() will wait for the child with a process ID equal to (pid_t)id.
If idtype is P_GID waitid() will wait for any child with a process group ID equal to (pid_t)id.
If idtype is P_ALL waitid() will wait for any children and id is ignored.
The infop argument must point to a siginfo_t structure. If waitid() returns because a child process was found that specified the conditions indicated by the arguments idtype and options then the structure pointed to by infop will be filled in by the system with the status of the process. The si_signo member will always be equal to SIGCHLD.
If waitid() returns due to the change of state of one of its children, it returns 0.