OSDN Git Service

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