]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/wait4.2
mknod.2: tfix
[thirdparty/man-pages.git] / man2 / wait4.2
CommitLineData
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.\"
09b8afdc 33.TH WAIT4 2 2018-04-30 "Linux" "Linux Programmer's Manual"
fea681da 34.SH NAME
fe4992a7 35wait3, 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>
68e4db0a 42.PP
36f8fb2b 43.BI "pid_t wait3(int *" "wstatus" ", int " options ,
521bf584 44.BI " struct rusage *" rusage );
68e4db0a 45.PP
36f8fb2b 46.BI "pid_t wait4(pid_t " pid ", int *" wstatus ", int " options ,
521bf584 47.BI " struct rusage *" rusage );
fea681da 48.fi
68e4db0a 49.PP
cc4615cc
MK
50.in -4n
51Feature Test Macro Requirements for glibc (see
52.BR feature_test_macros (7)):
53.in
68e4db0a 54.PP
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
218d4d5b 70These functions are nonstandard; in new programs, the use of
85d301e1
AB
71.BR waitpid (2)
72or
73.BR waitid (2)
218d4d5b 74is preferable.
efeece04 75.PP
fea681da 76The
fe4992a7
MK
77.BR wait3 ()
78and
79.BR wait4 ()
80system calls are similar to
81.BR waitpid (2),
82but additionally return resource usage information about the
83child in the structure pointed to by
84.IR rusage .
85.PP
86Other than the use of the
87.I rusage
88argument, the following
89.BR wait3 ()
90call:
408731d4
MK
91.PP
92.in +4n
93.EX
94wait3(wstatus, options, rusage);
95.EE
96.in
97.PP
fe4992a7 98is equivalent to:
408731d4
MK
99.PP
100.in +4n
101.EX
102waitpid(\-1, wstatus, options);
103.EE
104.in
105.PP
fe4992a7
MK
106Similarly, the following
107.BR wait4 ()
108call:
408731d4
MK
109.PP
110.in +4n
111.EX
112wait4(pid, wstatus, options, rusage);
113.EE
114.in
115.PP
fe4992a7 116is equivalent to:
408731d4
MK
117.PP
118.in +4n
119.EX
120waitpid(pid, wstatus, options);
121.EE
122.in
123.PP
fe4992a7
MK
124In other words,
125.BR wait3 ()
126waits of any child, while
127.BR wait4 ()
128can be used to select a specific child, or children, on which to wait.
129See
130.BR wait (2)
131for further details.
fea681da
MK
132.PP
133If
134.I rusage
8478ee02 135is not NULL, the
fe4992a7
MK
136.I struct rusage
137to which it points will be filled with accounting information
138about the child.
139See
fea681da
MK
140.BR getrusage (2)
141for details.
47297adb 142.SH RETURN VALUE
fe4992a7 143As for
540036b2 144.BR waitpid (2).
fea681da 145.SH ERRORS
fe4992a7 146As for
540036b2 147.BR waitpid (2).
47297adb 148.SH CONFORMING TO
44a2c328 1494.3BSD.
efeece04 150.PP
0ac42204
MK
151SUSv1 included a specification of
152.BR wait3 ();
153SUSv2 included
154.BR wait3 (),
155but marked it LEGACY;
156SUSv3 removed it.
fea681da
MK
157.SH NOTES
158Including
159.I <sys/time.h>
160is not required these days, but increases portability.
161(Indeed,
162.I <sys/resource.h>
163defines the
164.I rusage
165structure with fields of type
166.I struct timeval
167defined in
168.IR <sys/time.h> .)
0722a578 169.SS C library/kernel differences
e0d16ae5
MK
170On Linux,
171.BR wait3 ()
172is a library function implemented on top of the
173.BR wait4 ()
174system call.
47297adb 175.SH SEE ALSO
fe4992a7 176.BR fork (2),
fea681da 177.BR getrusage (2),
fe4992a7 178.BR sigaction (2),
fea681da
MK
179.BR signal (2),
180.BR wait (2),
181.BR signal (7)