]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/wait4.2
wait4.2: Update wait3() feature test macro requirements for changes in glibc 2.26
[thirdparty/man-pages.git] / man2 / wait4.2
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and Copyright (c) 2004 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Modified Sat Jul 24 13:32:44 1993 by Rik Faith (faith@cs.unc.edu)
27 .\" Modified Mon Jun 23 14:09:52 1997 by aeb - add EINTR.
28 .\" Modified Tue Jul 7 12:26:42 1998 by aeb - changed return value wait3
29 .\" Modified 2004-11-11, Michael Kerrisk <mtk.manpages@gmail.com>
30 .\" Rewrote much of this page, and removed much duplicated text,
31 .\" replacing with pointers to wait.2
32 .\"
33 .TH WAIT4 2 2018-04-30 "Linux" "Linux Programmer's Manual"
34 .SH NAME
35 wait3, wait4 \- wait for process to change state, BSD style
36 .SH SYNOPSIS
37 .nf
38 .B #include <sys/types.h>
39 .B #include <sys/time.h>
40 .B #include <sys/resource.h>
41 .B #include <sys/wait.h>
42 .PP
43 .BI "pid_t wait3(int *" "wstatus" ", int " options ,
44 .BI " struct rusage *" rusage );
45 .PP
46 .BI "pid_t wait4(pid_t " pid ", int *" wstatus ", int " options ,
47 .BI " struct rusage *" rusage );
48 .fi
49 .PP
50 .in -4n
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
53 .in
54 .PP
55 .ad l
56 .BR wait3 ():
57 Since glibc 2.26:
58 _DEFAULT_SOURCE ||
59 (_XOPEN_SOURCE\ >=\ 500 &&
60 ! (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600))
61 From glibc 2.19 to 2.25:
62 _DEFAULT_SOURCE || _XOPEN_SOURCE\ >=\ 500
63 Glibc 2.19 and earlier:
64 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
65 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
66 .br
67 .BR wait4 ():
68 Since glibc 2.19:
69 _DEFAULT_SOURCE
70 Glibc 2.19 and earlier:
71 _BSD_SOURCE
72 .ad
73 .SH DESCRIPTION
74 These functions are nonstandard; in new programs, the use of
75 .BR waitpid (2)
76 or
77 .BR waitid (2)
78 is preferable.
79 .PP
80 The
81 .BR wait3 ()
82 and
83 .BR wait4 ()
84 system calls are similar to
85 .BR waitpid (2),
86 but additionally return resource usage information about the
87 child in the structure pointed to by
88 .IR rusage .
89 .PP
90 Other than the use of the
91 .I rusage
92 argument, the following
93 .BR wait3 ()
94 call:
95 .PP
96 .in +4n
97 .EX
98 wait3(wstatus, options, rusage);
99 .EE
100 .in
101 .PP
102 is equivalent to:
103 .PP
104 .in +4n
105 .EX
106 waitpid(\-1, wstatus, options);
107 .EE
108 .in
109 .PP
110 Similarly, the following
111 .BR wait4 ()
112 call:
113 .PP
114 .in +4n
115 .EX
116 wait4(pid, wstatus, options, rusage);
117 .EE
118 .in
119 .PP
120 is equivalent to:
121 .PP
122 .in +4n
123 .EX
124 waitpid(pid, wstatus, options);
125 .EE
126 .in
127 .PP
128 In other words,
129 .BR wait3 ()
130 waits of any child, while
131 .BR wait4 ()
132 can be used to select a specific child, or children, on which to wait.
133 See
134 .BR wait (2)
135 for further details.
136 .PP
137 If
138 .I rusage
139 is not NULL, the
140 .I struct rusage
141 to which it points will be filled with accounting information
142 about the child.
143 See
144 .BR getrusage (2)
145 for details.
146 .SH RETURN VALUE
147 As for
148 .BR waitpid (2).
149 .SH ERRORS
150 As for
151 .BR waitpid (2).
152 .SH CONFORMING TO
153 4.3BSD.
154 .PP
155 SUSv1 included a specification of
156 .BR wait3 ();
157 SUSv2 included
158 .BR wait3 (),
159 but marked it LEGACY;
160 SUSv3 removed it.
161 .SH NOTES
162 Including
163 .I <sys/time.h>
164 is not required these days, but increases portability.
165 (Indeed,
166 .I <sys/resource.h>
167 defines the
168 .I rusage
169 structure with fields of type
170 .I struct timeval
171 defined in
172 .IR <sys/time.h> .)
173 .SS C library/kernel differences
174 On Linux,
175 .BR wait3 ()
176 is a library function implemented on top of the
177 .BR wait4 ()
178 system call.
179 .SH SEE ALSO
180 .BR fork (2),
181 .BR getrusage (2),
182 .BR sigaction (2),
183 .BR signal (2),
184 .BR wait (2),
185 .BR signal (7)