1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and Copyright (c) 2004 by Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
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
13 .TH wait4 2 (date) "Linux man-pages (unreleased)"
15 wait3, wait4 \- wait for process to change state, BSD style
18 .RI ( libc ", " \-lc )
21 .B #include <sys/wait.h>
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 );
30 Feature Test Macro Requirements for glibc (see
31 .BR feature_test_macros (7)):
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
52 glibc 2.19 and earlier:
56 These functions are nonstandard; in new programs, the use of
66 system calls are similar to
68 but additionally return resource usage information about the
69 child in the structure pointed to by
72 Other than the use of the
74 argument, the following
80 wait3(wstatus, options, rusage);
88 waitpid(\-1, wstatus, options);
92 Similarly, the following
98 wait4(pid, wstatus, options, rusage);
106 waitpid(pid, wstatus, options);
112 waits of any child, while
114 can be used to select a specific child, or children, on which to wait.
123 to which it points will be filled with accounting information
139 SUSv1 included a specification of
143 but marked it LEGACY;
148 is not required these days, but increases portability.
153 structure with fields of type
157 .SS C library/kernel differences
160 is a library function implemented on top of the