1waitid(2) System Calls waitid(2)
2
3
4
6 waitid - wait for child process to change state
7
9 #include <wait.h>
10
11 int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
12
13
15 The waitid() function suspends the calling process until one of its
16 child processes changes state. It records the current state of a child
17 in the structure pointed to by infop. It returns immediately if a
18 child process changed state prior to the call.
19
20
21 The idtype and id arguments specify which children waitid() is to
22 wait for, as follows:
23
24 o If idtype is P_PID, waitid() waits for the child with a
25 process ID equal to (pid_t)id.
26
27 o If idtype is P_PGID, waitid() waits for any child with a
28 process group ID equal to (pid_t)id.
29
30 o If idtype is P_ALL, waitid() waits for any child and id is
31 ignored.
32
33
34 The options argument is used to specify which state changes waitid() is
35 to wait for. It is formed by bitwise OR operation of any of the follow‐
36 ing flags:
37
38 WCONTINUED Return the status for any child that was stopped and has
39 been continued.
40
41
42 WEXITED Wait for process(es) to exit.
43
44
45 WNOHANG Return immediately.
46
47
48 WNOWAIT Keep the process in a waitable state.
49
50
51 WSTOPPED Wait for and return the process status of any child that
52 has stopped upon receipt of a signal.
53
54
55 WTRAPPED Wait for traced process(es) to become trapped or reach a
56 breakpoint (see ptrace(3C)).
57
58
59
60 The infop argument must point to a siginfo_t structure, as defined in
61 siginfo.h(3HEAD). If waitid() returns because a child process was found
62 that satisfies the conditions indicated by the arguments idtype and
63 options, then the structure pointed to by infop will be filled by the
64 system with the status of the process. The si_signo member will always
65 be equal to SIGCHLD.
66
67
68 One instance of a SIGCHLD signal is queued for each child process whose
69 status has changed. If waitid() returns because the status of a child
70 process is available and WNOWAIT was not specified in options, any
71 pending SIGCHLD signal associated with the process ID of that child
72 process is discarded. Any other pending SIGCHLD signals remain pending.
73
75 If waitid() returns due to a change of state of one of its children and
76 WNOHANG was not used, 0 is returned. Otherwise, −1 is returned and
77 errno is set to indicate the error. If WNOHANG was used, 0 can be
78 returned (indicating no error); however, no children may have changed
79 state if info->si_pid is 0.
80
82 The waitid() function will fail if:
83
84 ECHILD The set of processes specified by idtype and id does not con‐
85 tain any unwaited processes.
86
87
88 EFAULT The infop argument points to an illegal address.
89
90
91 EINTR The waitid() function was interrupted due to the receipt of a
92 signal by the calling process.
93
94
95 EINVAL An invalid value was specified for options, or idtype and id
96 specify an invalid set of processes.
97
98
100 With options equal to WEXITED | WTRAPPED, waitid() is equivalent to
101 waitpid(3C). With idtype equal to P_ALL and options equal to WEXITED |
102 WTRAPPED, waitid() is equivalent to wait(3C).
103
105 See attributes(5) for descriptions of the following attributes:
106
107
108
109
110 ┌─────────────────────────────┬─────────────────────────────┐
111 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
112 ├─────────────────────────────┼─────────────────────────────┤
113 │Interface Stability │Standard │
114 ├─────────────────────────────┼─────────────────────────────┤
115 │MT-Level │Async-Signal-Safe │
116 └─────────────────────────────┴─────────────────────────────┘
117
119 Intro(2), exec(2), exit(2), fork(2), pause(2), sigaction(2),
120 ptrace(3C), signal(3C), siginfo.h(3HEAD), wait(3C), waitpid(3C),
121 attributes(5), standards(5)
122
123
124
125SunOS 5.11 9 Jun 2004 waitid(2)