1WAITID(P) POSIX Programmer's Manual WAITID(P)
2
3
4
6 waitid - wait for a child process to change state
7
9 #include <sys/wait.h>
10
11 int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
12
13
15 The waitid() function shall suspend the calling thread until one child
16 of the process containing the calling thread changes state. It records
17 the current state of a child in the structure pointed to by infop. If a
18 child process changed state prior to the call to waitid(), waitid()
19 shall return immediately. If more than one thread is suspended in
20 wait() or waitpid() waiting for termination of the same process,
21 exactly one thread shall return the process status at the time of the
22 target process termination.
23
24 The idtype and id arguments are used to specify which children waitid()
25 waits for.
26
27 If idtype is P_PID, waitid() shall wait for the child with a process ID
28 equal to (pid_t)id.
29
30 If idtype is P_PGID, waitid() shall wait for any child with a process
31 group ID equal to (pid_t)id.
32
33 If idtype is P_ALL, waitid() shall wait for any children and id is
34 ignored.
35
36 The options argument is used to specify which state changes waitid()
37 shall wait for. It is formed by OR'ing together one or more of the fol‐
38 lowing flags:
39
40 WEXITED
41 Wait for processes that have exited.
42
43 WSTOPPED
44 Status shall be returned for any child that has stopped upon
45 receipt of a signal.
46
47 WCONTINUED
48 Status shall be returned for any child that was stopped and has
49 been continued.
50
51 WNOHANG
52 Return immediately if there are no children to wait for.
53
54 WNOWAIT
55 Keep the process whose status is returned in infop in a waitable
56 state. This shall not affect the state of the process; the
57 process may be waited for again after this call completes.
58
59
60 The application shall ensure that the infop argument points to a sig‐
61 info_t structure. If waitid() returns because a child process was found
62 that satisfied the conditions indicated by the arguments idtype and
63 options, then the structure pointed to by infop shall be filled in by
64 the system with the status of the process. The si_signo member shall
65 always be equal to SIGCHLD.
66
68 If WNOHANG was specified and there are no children to wait for, 0 shall
69 be returned. If waitid() returns due to the change of state of one of
70 its children, 0 shall be returned. Otherwise, -1 shall be returned and
71 errno set to indicate the error.
72
74 The waitid() function shall fail if:
75
76 ECHILD The calling process has no existing unwaited-for child pro‐
77 cesses.
78
79 EINTR The waitid() function was interrupted by a signal.
80
81 EINVAL An invalid value was specified for options, or idtype and id
82 specify an invalid set of processes.
83
84
85 The following sections are informative.
86
88 None.
89
91 None.
92
94 None.
95
97 None.
98
100 exec() , exit() , wait() , the Base Definitions volume of
101 IEEE Std 1003.1-2001, <sys/wait.h>
102
104 Portions of this text are reprinted and reproduced in electronic form
105 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
106 -- Portable Operating System Interface (POSIX), The Open Group Base
107 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
108 Electrical and Electronics Engineers, Inc and The Open Group. In the
109 event of any discrepancy between this version and the original IEEE and
110 The Open Group Standard, the original IEEE and The Open Group Standard
111 is the referee document. The original Standard can be obtained online
112 at http://www.opengroup.org/unix/online.html .
113
114
115
116IEEE/The Open Group 2003 WAITID(P)