9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man2 / waitid.2
blob81065f03a5d3dceb26842effc4c359b7a4b39ce4
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
45 .\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH WAITID 2 "Jun 9, 2004"
48 .SH NAME
49 waitid \- wait for child process to change state
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <wait.h>
55 \fBint\fR \fBwaitid\fR(\fBidtype_t\fR \fIidtype\fR, \fBid_t\fR \fIid\fR, \fBsiginfo_t *\fR\fIinfop\fR, \fBint\fR \fIoptions\fR);
56 .fi
58 .SH DESCRIPTION
59 .sp
60 .LP
61 The \fBwaitid()\fR function suspends the calling process until one of its child
62 processes changes state. It records the current state of a child in the
63 structure pointed to by \fIinfop\fR. It returns immediately if a child process
64 changed state prior to the call.
65 .sp
66 .LP
67 The \fIidtype\fR and  \fIid\fR arguments specify which children  \fBwaitid()\fR
68 is to wait for, as follows:
69 .RS +4
70 .TP
71 .ie t \(bu
72 .el o
73 If  \fIidtype\fR is \fBP_PID\fR, \fBwaitid()\fR waits for the child with a
74 process \fBID\fR equal to \fB(pid_t)\fR\fIid\fR.
75 .RE
76 .RS +4
77 .TP
78 .ie t \(bu
79 .el o
80 If \fIidtype\fR is \fBP_PGID\fR,  \fBwaitid()\fR waits for any child with a
81 process group \fBID\fR equal to \fB(pid_t)\fR\fIid\fR.
82 .RE
83 .RS +4
84 .TP
85 .ie t \(bu
86 .el o
87 If \fIidtype\fR is \fBP_ALL\fR, \fBwaitid()\fR waits for any child and \fIid\fR
88 is ignored.
89 .RE
90 .sp
91 .LP
92 The \fIoptions\fR argument is used to specify which state changes
93 \fBwaitid()\fR is to wait for. It is formed by bitwise \fBOR\fR operation of
94 any of the following flags:
95 .sp
96 .ne 2
97 .na
98 \fB\fBWCONTINUED\fR\fR
99 .ad
100 .RS 14n
101 Return the status for any child that was stopped and has been continued.
105 .ne 2
107 \fB\fBWEXITED\fR\fR
109 .RS 14n
110 Wait for process(es) to exit.
114 .ne 2
116 \fB\fBWNOHANG\fR\fR
118 .RS 14n
119 Return immediately.
123 .ne 2
125 \fB\fBWNOWAIT\fR\fR
127 .RS 14n
128 Keep the process in a waitable state.
132 .ne 2
134 \fB\fBWSTOPPED\fR\fR
136 .RS 14n
137 Wait for and return the process status of any child that has  stopped upon
138 receipt of a signal.
142 .ne 2
144 \fB\fBWTRAPPED\fR\fR
146 .RS 14n
147 Wait for traced process(es) to become trapped or reach a breakpoint (see
148 \fBptrace\fR(3C)).
153 The \fIinfop\fR argument must point to a \fBsiginfo_t\fR structure, as defined
154 in \fBsiginfo.h\fR(3HEAD). If \fBwaitid()\fR returns because a child process
155 was found that satisfies the conditions indicated by the arguments \fIidtype\fR
156 and \fIoptions\fR, then the structure pointed to by \fIinfop\fR will be filled
157 by the system with the status of the process. The \fBsi_signo\fR member will
158 always be equal to \fBSIGCHLD\fR.
161 One instance of a \fBSIGCHLD\fR signal is queued for each child process whose
162 status has changed. If \fBwaitid()\fR returns because the status of a child
163 process is available and \fBWNOWAIT\fR was not specified in \fIoptions\fR, any
164 pending \fBSIGCHLD\fR signal associated with the process ID of that child
165 process is discarded. Any other pending \fBSIGCHLD\fR signals remain pending.
166 .SH RETURN VALUES
169 If \fBwaitid()\fR returns due to a change of state of one of its children and
170 \fBWNOHANG\fR was not used,  \fB0\fR is returned.  Otherwise, \fB\(mi1\fR is
171 returned and  \fBerrno\fR is set to indicate the error. If \fBWNOHANG\fR was
172 used,  \fB0\fR can be returned (indicating no error); however, no children may
173 have changed state if \fBinfo->si_pid\fR is \fB0\fR.
174 .SH ERRORS
177 The \fBwaitid()\fR function will fail if:
179 .ne 2
181 \fB\fBECHILD\fR\fR
183 .RS 10n
184 The set of processes specified by \fIidtype\fR and \fIid\fR does not contain
185 any unwaited processes.
189 .ne 2
191 \fB\fBEFAULT\fR\fR
193 .RS 10n
194 The \fIinfop\fR argument points to an illegal address.
198 .ne 2
200 \fB\fBEINTR\fR\fR
202 .RS 10n
203 The \fBwaitid()\fR function was interrupted due to the receipt of a signal by
204 the calling process.
208 .ne 2
210 \fB\fBEINVAL\fR\fR
212 .RS 10n
213 An invalid value was specified for \fIoptions\fR, or \fIidtype\fR and \fIid\fR
214 specify an invalid set of processes.
217 .SH USAGE
220 With \fIoptions\fR equal to \fBWEXITED\fR | \fBWTRAPPED\fR, \fBwaitid()\fR is
221 equivalent to \fBwaitpid\fR(3C). With \fIidtype\fR equal to \fBP_ALL\fR and
222 \fIoptions\fR equal to \fBWEXITED\fR | \fBWTRAPPED\fR, \fBwaitid()\fR is
223 equivalent to \fBwait\fR(3C).
224 .SH ATTRIBUTES
227 See \fBattributes\fR(5) for descriptions of the following attributes:
232 box;
233 c | c
234 l | l .
235 ATTRIBUTE TYPE  ATTRIBUTE VALUE
237 Interface Stability     Standard
239 MT-Level        Async-Signal-Safe
242 .SH SEE ALSO
245 \fBIntro\fR(2), \fBexec\fR(2), \fBexit\fR(2), \fBfork\fR(2), \fBpause\fR(2),
246 \fBsigaction\fR(2), \fBptrace\fR(3C), \fBsignal\fR(3C), \fBsiginfo.h\fR(3HEAD),
247 \fBwait\fR(3C), \fBwaitpid\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)