OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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  2008-09-28 "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 .BR wait3 ():
57 _BSD_SOURCE
58 .br
59 .BR wait4 ():
60 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
61 .SH DESCRIPTION
62 The
63 .BR wait3 ()
64 and
65 .BR wait4 ()
66 system calls are similar to
67 .BR waitpid (2),
68 but additionally return resource usage information about the
69 child in the structure pointed to by
70 .IR rusage .
71 .PP
72 Other than the use of the
73 .I rusage
74 argument, the following
75 .BR wait3 ()
76 call:
77 .nf
78
79     wait3(status, options, rusage);
80
81 .fi
82 is equivalent to:
83 .nf
84
85     waitpid(\-1, status, options);
86
87 .fi
88 Similarly, the following
89 .BR wait4 ()
90 call:
91 .nf
92
93     wait4(pid, status, options, rusage);
94
95 .fi
96 is equivalent to:
97 .nf
98
99     waitpid(pid, status, options);
100
101 .fi
102 In other words,
103 .BR wait3 ()
104 waits of any child, while
105 .BR wait4 ()
106 can be used to select a specific child, or children, on which to wait.
107 See
108 .BR wait (2)
109 for further details.
110 .PP
111 If
112 .I rusage
113 is not NULL, the
114 .I struct rusage
115 to which it points will be filled with accounting information
116 about the child.
117 See
118 .BR getrusage (2)
119 for details.
120 .SH "RETURN VALUE"
121 As for
122 .BR waitpid (2).
123 .SH ERRORS
124 As for
125 .BR waitpid (2).
126 .SH "CONFORMING TO"
127 4.3BSD.
128 .SH NOTES
129 Including
130 .I <sys/time.h>
131 is not required these days, but increases portability.
132 (Indeed,
133 .I <sys/resource.h>
134 defines the
135 .I rusage
136 structure with fields of type
137 .I struct timeval
138 defined in
139 .IR <sys/time.h> .)
140
141 On Linux,
142 .BR wait3 ()
143 is a library function implemented on top of the
144 .BR wait4 ()
145 system call.
146 .SH "SEE ALSO"
147 .BR fork (2),
148 .BR getrusage (2),
149 .BR sigaction (2),
150 .BR signal (2),
151 .BR wait (2),
152 .BR signal (7)