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