1WAIT4(2)                   Linux Programmer's Manual                  WAIT4(2)
2
3
4

NAME

6       wait3, wait4 - wait for process to change state, BSD style
7

SYNOPSIS

9       #include <sys/wait.h>
10
11       pid_t wait3(int *wstatus, int options, struct rusage *rusage);
12       pid_t wait4(pid_t pid, int *wstatus, int options,
13                   struct rusage *rusage);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       wait3():
18           Since glibc 2.26:
19               _DEFAULT_SOURCE
20                   || (_XOPEN_SOURCE >= 500 &&
21                       ! (_POSIX_C_SOURCE >= 200112L
22                          || _XOPEN_SOURCE >= 600))
23           From glibc 2.19 to 2.25:
24               _DEFAULT_SOURCE || _XOPEN_SOURCE >= 500
25           Glibc 2.19 and earlier:
26               _BSD_SOURCE || _XOPEN_SOURCE >= 500
27
28       wait4():
29           Since glibc 2.19:
30               _DEFAULT_SOURCE
31           Glibc 2.19 and earlier:
32               _BSD_SOURCE
33

DESCRIPTION

35       These functions are nonstandard; in new programs, the use of waitpid(2)
36       or waitid(2) is preferable.
37
38       The wait3() and wait4() system calls are similar to waitpid(2), but ad‐
39       ditionally  return  resource  usage  information about the child in the
40       structure pointed to by rusage.
41
42       Other than the use of the rusage argument, the following wait3() call:
43
44           wait3(wstatus, options, rusage);
45
46       is equivalent to:
47
48           waitpid(-1, wstatus, options);
49
50       Similarly, the following wait4() call:
51
52           wait4(pid, wstatus, options, rusage);
53
54       is equivalent to:
55
56           waitpid(pid, wstatus, options);
57
58       In other words, wait3() waits of any child, while wait4() can  be  used
59       to select a specific child, or children, on which to wait.  See wait(2)
60       for further details.
61
62       If rusage is not NULL, the struct rusage to which  it  points  will  be
63       filled  with  accounting information about the child.  See getrusage(2)
64       for details.
65

RETURN VALUE

67       As for waitpid(2).
68

ERRORS

70       As for waitpid(2).
71

CONFORMING TO

73       4.3BSD.
74
75       SUSv1 included a specification of wait3(); SUSv2 included wait3(),  but
76       marked it LEGACY; SUSv3 removed it.
77

NOTES

79       Including <sys/time.h> is not required these days, but increases porta‐
80       bility.  (Indeed, <sys/resource.h> defines the  rusage  structure  with
81       fields of type struct timeval defined in <sys/time.h>.)
82
83   C library/kernel differences
84       On  Linux,  wait3()  is  a  library  function implemented on top of the
85       wait4() system call.
86

SEE ALSO

88       fork(2), getrusage(2), sigaction(2), signal(2), wait(2), signal(7)
89

COLOPHON

91       This page is part of release 5.12 of the Linux  man-pages  project.   A
92       description  of  the project, information about reporting bugs, and the
93       latest    version    of    this    page,    can     be     found     at
94       https://www.kernel.org/doc/man-pages/.
95
96
97
98Linux                             2021-03-22                          WAIT4(2)
Impressum