]>
Commit | Line | Data |
---|---|---|
1130df60 | 1 | .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) |
616c2730 | 2 | .\" and Copyright (c) 2004 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 3 | .\" |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
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. | |
c13182ef | 13 | .\" |
fea681da MK |
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. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
fea681da MK |
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 | |
c11b1abf | 29 | .\" Modified 2004-11-11, Michael Kerrisk <mtk.manpages@gmail.com> |
c13182ef | 30 | .\" Rewrote much of this page, and removed much duplicated text, |
fe4992a7 | 31 | .\" replacing with pointers to wait.2 |
fea681da | 32 | .\" |
97986708 | 33 | .TH WAIT4 2 2016-03-15 "Linux" "Linux Programmer's Manual" |
fea681da | 34 | .SH NAME |
fe4992a7 | 35 | wait3, wait4 \- wait for process to change state, BSD style |
fea681da MK |
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> | |
fe4992a7 | 42 | .sp |
36f8fb2b | 43 | .BI "pid_t wait3(int *" "wstatus" ", int " options , |
521bf584 | 44 | .BI " struct rusage *" rusage ); |
fea681da | 45 | .sp |
36f8fb2b | 46 | .BI "pid_t wait4(pid_t " pid ", int *" wstatus ", int " options , |
521bf584 | 47 | .BI " struct rusage *" rusage ); |
fea681da | 48 | .fi |
cc4615cc MK |
49 | .sp |
50 | .in -4n | |
51 | Feature Test Macro Requirements for glibc (see | |
52 | .BR feature_test_macros (7)): | |
53 | .in | |
54 | .sp | |
947c9189 | 55 | .ad l |
cc4615cc | 56 | .BR wait3 (): |
51c612fb MK |
57 | Since glibc 2.19: |
58 | _DEFAULT_SOURCE || _XOPEN_SOURCE\ >=\ 500 | |
59 | Glibc 2.19 and earlier: | |
60 | _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 | |
61 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED | |
cc4615cc MK |
62 | .br |
63 | .BR wait4 (): | |
51c612fb MK |
64 | Since glibc 2.19: |
65 | _DEFAULT_SOURCE | |
66 | Glibc 2.19 and earlier: | |
67 | _BSD_SOURCE | |
947c9189 | 68 | .ad |
fea681da | 69 | .SH DESCRIPTION |
85d301e1 AB |
70 | These functions are obsolete; use |
71 | .BR waitpid (2) | |
72 | or | |
73 | .BR waitid (2) | |
74 | in new programs. | |
75 | ||
fea681da | 76 | The |
fe4992a7 MK |
77 | .BR wait3 () |
78 | and | |
79 | .BR wait4 () | |
80 | system calls are similar to | |
81 | .BR waitpid (2), | |
82 | but additionally return resource usage information about the | |
83 | child in the structure pointed to by | |
84 | .IR rusage . | |
85 | .PP | |
86 | Other than the use of the | |
87 | .I rusage | |
88 | argument, the following | |
89 | .BR wait3 () | |
90 | call: | |
91 | .nf | |
fea681da | 92 | |
36f8fb2b | 93 | wait3(wstatus, options, rusage); |
fea681da | 94 | |
fe4992a7 MK |
95 | .fi |
96 | is equivalent to: | |
97 | .nf | |
98 | ||
36f8fb2b | 99 | waitpid(\-1, wstatus, options); |
fe4992a7 MK |
100 | |
101 | .fi | |
102 | Similarly, the following | |
103 | .BR wait4 () | |
104 | call: | |
105 | .nf | |
106 | ||
36f8fb2b | 107 | wait4(pid, wstatus, options, rusage); |
fe4992a7 MK |
108 | |
109 | .fi | |
110 | is equivalent to: | |
111 | .nf | |
112 | ||
36f8fb2b | 113 | waitpid(pid, wstatus, options); |
fe4992a7 MK |
114 | |
115 | .fi | |
116 | In other words, | |
117 | .BR wait3 () | |
118 | waits of any child, while | |
119 | .BR wait4 () | |
120 | can be used to select a specific child, or children, on which to wait. | |
121 | See | |
122 | .BR wait (2) | |
123 | for further details. | |
fea681da MK |
124 | .PP |
125 | If | |
126 | .I rusage | |
8478ee02 | 127 | is not NULL, the |
fe4992a7 MK |
128 | .I struct rusage |
129 | to which it points will be filled with accounting information | |
130 | about the child. | |
131 | See | |
fea681da MK |
132 | .BR getrusage (2) |
133 | for details. | |
47297adb | 134 | .SH RETURN VALUE |
fe4992a7 | 135 | As for |
540036b2 | 136 | .BR waitpid (2). |
fea681da | 137 | .SH ERRORS |
fe4992a7 | 138 | As for |
540036b2 | 139 | .BR waitpid (2). |
47297adb | 140 | .SH CONFORMING TO |
44a2c328 | 141 | 4.3BSD. |
0ac42204 MK |
142 | |
143 | SUSv1 included a specification of | |
144 | .BR wait3 (); | |
145 | SUSv2 included | |
146 | .BR wait3 (), | |
147 | but marked it LEGACY; | |
148 | SUSv3 removed it. | |
fea681da MK |
149 | .SH NOTES |
150 | Including | |
151 | .I <sys/time.h> | |
152 | is not required these days, but increases portability. | |
153 | (Indeed, | |
154 | .I <sys/resource.h> | |
155 | defines the | |
156 | .I rusage | |
157 | structure with fields of type | |
158 | .I struct timeval | |
159 | defined in | |
160 | .IR <sys/time.h> .) | |
0722a578 | 161 | .SS C library/kernel differences |
e0d16ae5 MK |
162 | On Linux, |
163 | .BR wait3 () | |
164 | is a library function implemented on top of the | |
165 | .BR wait4 () | |
166 | system call. | |
47297adb | 167 | .SH SEE ALSO |
fe4992a7 | 168 | .BR fork (2), |
fea681da | 169 | .BR getrusage (2), |
fe4992a7 | 170 | .BR sigaction (2), |
fea681da MK |
171 | .BR signal (2), |
172 | .BR wait (2), | |
173 | .BR signal (7) |