version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
WAIT4 |
|
|
2 |
!!!WAIT4 |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
NOTE |
|
|
9 |
CONFORMING TO |
|
|
10 |
SEE ALSO |
|
|
11 |
---- |
|
|
12 |
!!NAME |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
wait3, wait4 - wait for process termination, BSD style |
|
|
16 |
!!SYNOPSIS |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__#define _USE_BSD |
|
|
20 |
#include |
|
|
21 |
__''status''__, int__ ''options''__, |
|
|
22 |
struct rusage *__''rusage''__) |
|
|
23 |
pid_t wait4(pid_t__ ''pid''__, int *__''status''__, int__ ''options''__, |
|
|
24 |
struct rusage *__''rusage''__) |
|
|
25 |
__ |
|
|
26 |
!!DESCRIPTION |
|
|
27 |
|
|
|
28 |
|
|
|
29 |
The __wait3__ function suspends execution of the current |
|
|
30 |
process until a child has exited, or until a signal is |
|
|
31 |
delivered whose action is to terminate the current process |
|
|
32 |
or to call a signal handling function. If a child has |
|
|
33 |
already exited by the time of the call (a so-called |
|
|
34 |
__ |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
The __wait4__ function suspends execution of the current |
|
|
38 |
process until a child as specified by the ''pid'' |
|
|
39 |
argument has exited, or until a signal is delivered whose |
|
|
40 |
action is to terminate the current process or to call a |
|
|
41 |
signal handling function. If a child as requested by |
|
|
42 |
''pid'' has already exited by the time of the call (a |
|
|
43 |
so-called |
|
|
44 |
'' |
|
|
45 |
|
|
|
46 |
|
|
|
47 |
The value of ''pid'' can be one of: |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
which means to wait for any child process whose process |
|
|
53 |
group ID is equal to the absolute value of |
|
|
54 |
''pid''. |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
-1 |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
which means to wait for any child process; this is |
|
|
61 |
equivalent to calling __wait3__. |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
0 |
|
|
65 |
|
|
|
66 |
|
|
|
67 |
which means to wait for any child process whose process |
|
|
68 |
group ID is equal to that of the calling |
|
|
69 |
process. |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
which means to wait for the child whose process ID is equal |
|
|
75 |
to the value of ''pid''. |
|
|
76 |
|
|
|
77 |
|
|
|
78 |
The value of ''options'' is a bitwise OR of zero or more |
|
|
79 |
of the following constants: |
|
|
80 |
|
|
|
81 |
|
|
|
82 |
__WNOHANG__ |
|
|
83 |
|
|
|
84 |
|
|
|
85 |
which means to return immediately if no child is there to be |
|
|
86 |
waited for. |
|
|
87 |
|
|
|
88 |
|
|
|
89 |
__WUNTRACED__ |
|
|
90 |
|
|
|
91 |
|
|
|
92 |
which means to also return for children which are stopped, |
|
|
93 |
and whose status has not been reported. |
|
|
94 |
|
|
|
95 |
|
|
|
96 |
If ''status'' is not __NULL__, __wait3__ or |
|
|
97 |
__wait4__ store status information in the location |
|
|
98 |
pointed to by ''status''. |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
This status can be evaluated with the following macros |
|
|
102 |
(these macros take the stat buffer (an __int__) as an |
|
|
103 |
argument -- not a pointer to the buffer!): |
|
|
104 |
|
|
|
105 |
|
|
|
106 |
__WIFEXITED(__''status''__)__ |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
is non-zero if the child exited normally. |
|
|
110 |
|
|
|
111 |
|
|
|
112 |
__WEXITSTATUS(__''status''__)__ |
|
|
113 |
|
|
|
114 |
|
|
|
115 |
evaluates to the least significant eight bits of the return |
|
|
116 |
code of the child which terminated, which may have been set |
|
|
117 |
as the argument to a call to __exit()__ or as the |
|
|
118 |
argument for a __return__ statement in the main program. |
|
|
119 |
This macro can only be evaluated if __WIFEXITED__ |
|
|
120 |
returned non-zero. |
|
|
121 |
|
|
|
122 |
|
|
|
123 |
__WIFSIGNALED(__''status''__)__ |
|
|
124 |
|
|
|
125 |
|
|
|
126 |
returns true if the child process exited because of a signal |
|
|
127 |
which was not caught. |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
__WTERMSIG(__''status''__)__ |
|
|
131 |
|
|
|
132 |
|
|
|
133 |
returns the number of the signal that caused the child |
|
|
134 |
process to terminate. This macro can only be evaluated if |
|
|
135 |
__WIFSIGNALED__ returned non-zero. |
|
|
136 |
|
|
|
137 |
|
|
|
138 |
__WIFSTOPPED(__''status''__)__ |
|
|
139 |
|
|
|
140 |
|
|
|
141 |
returns true if the child process which caused the return is |
|
|
142 |
currently stopped; this is only possible if the call was |
|
|
143 |
done using __WUNTRACED__. |
|
|
144 |
|
|
|
145 |
|
|
|
146 |
__WSTOPSIG(__''status''__)__ |
|
|
147 |
|
|
|
148 |
|
|
|
149 |
returns the number of the signal which caused the child to |
|
|
150 |
stop. This macro can only be evaluated if __WIFSTOPPED__ |
|
|
151 |
returned non-zero. |
|
|
152 |
|
|
|
153 |
|
|
|
154 |
If ''rusage'' is not __NULL__, the __struct |
|
|
155 |
rusage__ as defined in '''' it |
|
|
156 |
points to will be filled with accounting information. See |
|
|
157 |
getrusage(2) for details. |
|
|
158 |
!!RETURN VALUE |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
The process ID of the child which exited, -1 on error (in |
|
|
162 |
particular, when no unwaited-for child processes of the |
|
|
163 |
specified kind exist) or zero if __WNOHANG__ was used and |
|
|
164 |
no child was available yet. In the latter two cases |
|
|
165 |
''errno'' will be set appropriately. |
|
|
166 |
!!ERRORS |
|
|
167 |
|
|
|
168 |
|
|
|
169 |
__ECHILD__ |
|
|
170 |
|
|
|
171 |
|
|
|
172 |
No unwaited-for child process as specified does |
|
|
173 |
exist. |
|
|
174 |
|
|
|
175 |
|
|
|
176 |
__ERESTARTSYS__ |
|
|
177 |
|
|
|
178 |
|
|
|
179 |
if __WNOHANG__ was not set and an unblocked signal or a |
|
|
180 |
__SIGCHLD__ was caught. This error is returned by the |
|
|
181 |
system call. The library interface is not allowed to return |
|
|
182 |
__ERESTARTSYS__, but will return |
|
|
183 |
__EINTR__. |
|
|
184 |
!!NOTE |
|
|
185 |
|
|
|
186 |
|
|
|
187 |
Including '''' is not required these |
|
|
188 |
days, but increases portability. (Indeed, |
|
|
189 |
'''' defines the ''rusage'' |
|
|
190 |
structure with fields of type ''struct timeval'' defined |
|
|
191 |
in ''''.) |
|
|
192 |
!!CONFORMING TO |
|
|
193 |
|
|
|
194 |
|
|
|
195 |
SVr4, POSIX.1 |
|
|
196 |
!!SEE ALSO |
|
|
197 |
|
|
|
198 |
|
|
|
199 |
signal(2), getrusage(2), wait(2), |
|
|
200 |
signal(7) |
|
|
201 |
---- |