1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
.TH wait 3
.SH NAME
wait \- check child process status
.SH SYNTAX
.B #include <wait.h>
int \fBwait_nohang\fP(&\fIwstat\fR);
.br
int \fBwait_stop\fP(&\fIwstat\fR);
.br
int \fBwait_stopnohang\fP(&\fIwstat\fR);
.br
int \fBwait_pid\fP(&\fIwstat\fR,\fIpid\fR);
int \fBwait_exitcode\fP(\fIwstat\fR);
.br
int \fBwait_crashed\fP(\fIwstat\fR);
.br
int \fBwait_stopped\fP(\fIwstat\fR);
.br
int \fBwait_stopsig\fP(\fIwstat\fR);
int \fIpid\fR;
.br
int \fIwstat\fR;
.SH DESCRIPTION
.B wait_nohang
looks for zombies (child processes that have exited).
If it sees a zombie,
it eliminates the zombie,
puts the zombie's exit status into
.IR wstat ,
and returns the zombie's process ID.
If there are several zombies,
.B wait_nohang
picks one.
If there are children but no zombies,
.B wait_nohang
returns 0.
If there are no children,
.B wait_nohang
returns -1,
setting
.B errno
appropriately.
.B wait_stopnohang
is similar to
.BR wait_nohang ,
but it also looks for children that have stopped.
.B wait_stop
is similar to
.BR wait_stopnohang ,
but if there are children it will pause waiting for one of them
to stop or exit.
.B wait_pid
waits for child process
.I pid
to exit.
It eliminates any zombie that shows up in the meantime,
discarding the exit status.
.B wait_stop
and
.B wait_pid
retry upon
.BR error_intr .
.SH "STATUS PARSING"
If the child stopped,
.B wait_stopped
is nonzero;
.B wait_stopsig
is the signal that caused the child to stop.
If the child exited by crashing,
.B wait_stopped
is zero;
.B wait_crashed
is nonzero.
If the child exited normally,
.B wait_stopped
is zero;
.B wait_crashed
is zero;
and
.B wait_exitcode
is the child's exit code.
.SH "SEE ALSO"
wait(2),
error(3)
|