Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
waitid - wait for status change of child processes
&pagelevel(4)&pagelevel
Syntax | #include <wait.h> int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); |
Description | The calling process is suspended by waitid() until one of the child processes changes its status. The current status of the relevant child process is entered in the structure pointed to by infop. If a child process has changed its status before the waitid() call, waitid() returns immediately. The idtype and id arguments indicate which child processes waitid() is to wait for. If idtype is P_PID , then waitid() waits for the child process with the process ID (pid_t) id. If idtype is P_PGID , then waitid() waits for one of the child processes with the process group ID (pid_t) id. If idtype is P_ALL , then waitid() waits for any child process and id is ignored.
The options argument is used to specify which status changes waitid() is to wait for. The status changes are specified via bitwise ORing of the following flags: WEXITED
| waits for processes to exit. | WTRAPPED
| waits for traced processes to be interrupted or reach a breakpoint (see ptrace()). | WSTOPPED
| waits and returns the process status of a child process which stopped after a signal was received. | WCONTINUED
| returns the status of a child process that was suspended and then resumed. | WNOHANG
| returns immediately if there are no child processes to be waited for. | WNOWAIT
| keeps the process whose status was returned in infop in a wait state. The status of this process is not affected. This process can be waited for again when the call is completed. |
infop must point to a siginfo_t structure, as it is defined in siginfo() . If waitid() returns because it has found a child process which fulfils the conditions specified in idtype and options, the system enters the status of this process in siginfo_t . The structure element si_signo always has the value SIGCHILD. If threads are used, the wait() and waitpid() functions affect the process or a thread in the following manner: The calling thread is suspended until the status of one of the child processes changes. |
Return val. | 0 | if waitid() returns because of a status change of a child process |
| -1 | otherwise. errno is set to indicate the error. |
Errors | waitid() will fail if at least one of the following occurs:
|
| ECHILD
| For the calling process there are no child processes which are not being waited for. |
| EINTR
| waitid() was interrupted because the calling process has received a signal.
|
| EINVAL
| An invalid value was passed for options, or idtype and id indicate an invalid number of process set. |
| EFAULT
| infop points to an invalid address. |
See also | exec , exit() , wait() , sys/wait.h .
|