1wait4(2)                      System Calls Manual                     wait4(2)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

71       As for waitpid(2).
72

ERRORS

74       As for waitpid(2).
75

STANDARDS

77       None.
78

HISTORY

80       4.3BSD.
81
82       SUSv1 included a specification of wait3(); SUSv2 included wait3(),  but
83       marked it LEGACY; SUSv3 removed it.
84
85       Including <sys/time.h> is not required these days, but increases porta‐
86       bility.  (Indeed, <sys/resource.h> defines the  rusage  structure  with
87       fields of type struct timeval defined in <sys/time.h>.)
88
89   C library/kernel differences
90       On  Linux,  wait3()  is  a  library  function implemented on top of the
91       wait4() system call.
92

SEE ALSO

94       fork(2), getrusage(2), sigaction(2), signal(2), wait(2), signal(7)
95
96
97
98Linux man-pages 6.05              2023-03-30                          wait4(2)
Impressum