OSDN Git Service

68e49adbd096869844b4ca82c9e5eccb9aafbeee
[linuxjm/LDP_man-pages.git] / original / man2 / wait4.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
4 .\" and Copyright (c) 2004 by Michael Kerrisk (mtk.manpages@gmail.com)
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" License.
26 .\"
27 .\" Modified Sat Jul 24 13:32:44 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Mon Jun 23 14:09:52 1997 by aeb - add EINTR.
29 .\" Modified Tue Jul  7 12:26:42 1998 by aeb - changed return value wait3
30 .\" Modified 2004-11-11, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"     Rewrote much of this page, and removed much duplicated text,
32 .\"             replacing with pointers to wait.2
33 .\"
34 .TH WAIT4 2  2010-09-20 "Linux" "Linux Programmer's Manual"
35 .SH NAME
36 wait3, wait4 \- wait for process to change state, BSD style
37 .SH SYNOPSIS
38 .nf
39 .B #include <sys/types.h>
40 .B #include <sys/time.h>
41 .B #include <sys/resource.h>
42 .B #include <sys/wait.h>
43 .sp
44 .BI "pid_t wait3(int *" "status" ", int " options ,
45 .BI "            struct rusage *" rusage );
46 .sp
47 .BI "pid_t wait4(pid_t " pid ", int *" status ", int " options ,
48 .BI "            struct rusage *" rusage );
49 .fi
50 .sp
51 .in -4n
52 Feature Test Macro Requirements for glibc (see
53 .BR feature_test_macros (7)):
54 .in
55 .sp
56 .ad l
57 .BR wait3 ():
58 .RS 4
59 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
60 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
61 .RE
62 .br
63 .BR wait4 ():
64 .RS 4
65 _BSD_SOURCE
66 .RE
67 .ad
68 .SH DESCRIPTION
69 The
70 .BR wait3 ()
71 and
72 .BR wait4 ()
73 system calls are similar to
74 .BR waitpid (2),
75 but additionally return resource usage information about the
76 child in the structure pointed to by
77 .IR rusage .
78 .PP
79 Other than the use of the
80 .I rusage
81 argument, the following
82 .BR wait3 ()
83 call:
84 .nf
85
86     wait3(status, options, rusage);
87
88 .fi
89 is equivalent to:
90 .nf
91
92     waitpid(\-1, status, options);
93
94 .fi
95 Similarly, the following
96 .BR wait4 ()
97 call:
98 .nf
99
100     wait4(pid, status, options, rusage);
101
102 .fi
103 is equivalent to:
104 .nf
105
106     waitpid(pid, status, options);
107
108 .fi
109 In other words,
110 .BR wait3 ()
111 waits of any child, while
112 .BR wait4 ()
113 can be used to select a specific child, or children, on which to wait.
114 See
115 .BR wait (2)
116 for further details.
117 .PP
118 If
119 .I rusage
120 is not NULL, the
121 .I struct rusage
122 to which it points will be filled with accounting information
123 about the child.
124 See
125 .BR getrusage (2)
126 for details.
127 .SH "RETURN VALUE"
128 As for
129 .BR waitpid (2).
130 .SH ERRORS
131 As for
132 .BR waitpid (2).
133 .SH "CONFORMING TO"
134 4.3BSD.
135 .SH NOTES
136 Including
137 .I <sys/time.h>
138 is not required these days, but increases portability.
139 (Indeed,
140 .I <sys/resource.h>
141 defines the
142 .I rusage
143 structure with fields of type
144 .I struct timeval
145 defined in
146 .IR <sys/time.h> .)
147
148 On Linux,
149 .BR wait3 ()
150 is a library function implemented on top of the
151 .BR wait4 ()
152 system call.
153 .SH "SEE ALSO"
154 .BR fork (2),
155 .BR getrusage (2),
156 .BR sigaction (2),
157 .BR signal (2),
158 .BR wait (2),
159 .BR signal (7)