Debian Codegraph @

upstream/debian-trixie/man2/wait4.2

raw
1 .\" Copyright (c) 1993 by Thomas Koenig ([email protected])
2 .\" and Copyright (c) 2004 by Michael Kerrisk <[email protected]>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" Modified Sat Jul 24 13:32:44 1993 by Rik Faith ([email protected])
7 .\" Modified Mon Jun 23 14:09:52 1997 by aeb - add EINTR.
8 .\" Modified Tue Jul 7 12:26:42 1998 by aeb - changed return value wait3
9 .\" Modified 2004-11-11, Michael Kerrisk <[email protected]>
10 .\" Rewrote much of this page, and removed much duplicated text,
11 .\" replacing with pointers to wait.2
12 .\"
13 .TH wait4 2 2024-05-02 "Linux man-pages 6.9.1"
14 .SH NAME
15 wait3, wait4 \- wait for process to change state, BSD style
16 .SH LIBRARY
17 Standard C library
18 .RI ( libc ", " \-lc )
19 .SH SYNOPSIS
20 .nf
21 .B #include <sys/wait.h>
22 .P
23 .BI "pid_t wait3(int *_Nullable " "wstatus" ", int " options ,
24 .BI " struct rusage *_Nullable " rusage );
25 .BI "pid_t wait4(pid_t " pid ", int *_Nullable " wstatus ", int " options ,
26 .BI " struct rusage *_Nullable " rusage );
27 .fi
28 .P
29 .RS -4
30 Feature Test Macro Requirements for glibc (see
31 .BR feature_test_macros (7)):
32 .RE
33 .P
34 .BR wait3 ():
35 .nf
36 Since glibc 2.26:
37 _DEFAULT_SOURCE
38 || (_XOPEN_SOURCE >= 500 &&
39 ! (_POSIX_C_SOURCE >= 200112L
40 || _XOPEN_SOURCE >= 600))
41 From glibc 2.19 to glibc 2.25:
42 _DEFAULT_SOURCE || _XOPEN_SOURCE >= 500
43 glibc 2.19 and earlier:
44 _BSD_SOURCE || _XOPEN_SOURCE >= 500
45 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
46 .fi
47 .P
48 .BR wait4 ():
49 .nf
50 Since glibc 2.19:
51 _DEFAULT_SOURCE
52 glibc 2.19 and earlier:
53 _BSD_SOURCE
54 .fi
55 .SH DESCRIPTION
56 These functions are nonstandard; in new programs, the use of
57 .BR waitpid (2)
58 or
59 .BR waitid (2)
60 is preferable.
61 .P
62 The
63 .BR wait3 ()
64 and
65 .BR wait4 ()
66 system calls are similar to
67 .BR waitpid (2),
68 but additionally return resource usage information about the
69 child in the structure pointed to by
70 .IR rusage .
71 .P
72 Other than the use of the
73 .I rusage
74 argument, the following
75 .BR wait3 ()
76 call:
77 .P
78 .in +4n
79 .EX
80 wait3(wstatus, options, rusage);
81 .EE
82 .in
83 .P
84 is equivalent to:
85 .P
86 .in +4n
87 .EX
88 waitpid(\-1, wstatus, options);
89 .EE
90 .in
91 .P
92 Similarly, the following
93 .BR wait4 ()
94 call:
95 .P
96 .in +4n
97 .EX
98 wait4(pid, wstatus, options, rusage);
99 .EE
100 .in
101 .P
102 is equivalent to:
103 .P
104 .in +4n
105 .EX
106 waitpid(pid, wstatus, options);
107 .EE
108 .in
109 .P
110 In other words,
111 .BR wait3 ()
112 waits of any child, while
113 .BR wait4 ()
114 can be used to select a specific child, or children, on which to wait.
115 See
116 .BR wait (2)
117 for further details.
118 .P
119 If
120 .I rusage
121 is not NULL, the
122 .I struct rusage
123 to which it points will be filled with accounting information
124 about the child.
125 See
126 .BR getrusage (2)
127 for details.
128 .SH RETURN VALUE
129 As for
130 .BR waitpid (2).
131 .SH ERRORS
132 As for
133 .BR waitpid (2).
134 .SH STANDARDS
135 None.
136 .SH HISTORY
137 4.3BSD.
138 .P
139 SUSv1 included a specification of
140 .BR wait3 ();
141 SUSv2 included
142 .BR wait3 (),
143 but marked it LEGACY;
144 SUSv3 removed it.
145 .P
146 Including
147 .I <sys/time.h>
148 is not required these days, but increases portability.
149 (Indeed,
150 .I <sys/resource.h>
151 defines the
152 .I rusage
153 structure with fields of type
154 .I struct timeval
155 defined in
156 .IR <sys/time.h> .)
157 .SS C library/kernel differences
158 On Linux,
159 .BR wait3 ()
160 is a library function implemented on top of the
161 .BR wait4 ()
162 system call.
163 .SH SEE ALSO
164 .BR fork (2),
165 .BR getrusage (2),
166 .BR sigaction (2),
167 .BR signal (2),
168 .BR wait (2),
169 .BR signal (7)