2 .\" Copyright 1989 AT&T. Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved. Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\" This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH WAITID 2 "Jun 9, 2004"
12 waitid \- wait for child process to change state
18 \fBint\fR \fBwaitid\fR(\fBidtype_t\fR \fIidtype\fR, \fBid_t\fR \fIid\fR, \fBsiginfo_t *\fR\fIinfop\fR, \fBint\fR \fIoptions\fR);
24 The \fBwaitid()\fR function suspends the calling process until one of its child
25 processes changes state. It records the current state of a child in the
26 structure pointed to by \fIinfop\fR. It returns immediately if a child process
27 changed state prior to the call.
30 The \fIidtype\fR and \fIid\fR arguments specify which children \fBwaitid()\fR
31 is to wait for, as follows:
36 If \fIidtype\fR is \fBP_PID\fR, \fBwaitid()\fR waits for the child with a
37 process \fBID\fR equal to \fB(pid_t)\fR\fIid\fR.
43 If \fIidtype\fR is \fBP_PGID\fR, \fBwaitid()\fR waits for any child with a
44 process group \fBID\fR equal to \fB(pid_t)\fR\fIid\fR.
50 If \fIidtype\fR is \fBP_ALL\fR, \fBwaitid()\fR waits for any child and \fIid\fR
55 The \fIoptions\fR argument is used to specify which state changes
56 \fBwaitid()\fR is to wait for. It is formed by bitwise \fBOR\fR operation of
57 any of the following flags:
61 \fB\fBWCONTINUED\fR\fR
64 Return the status for any child that was stopped and has been continued.
73 Wait for process(es) to exit.
91 Keep the process in a waitable state.
100 Wait for and return the process status of any child that has stopped upon
110 Wait for traced process(es) to become trapped or reach a breakpoint (see
116 The \fIinfop\fR argument must point to a \fBsiginfo_t\fR structure, as defined
117 in \fBsiginfo.h\fR(3HEAD). If \fBwaitid()\fR returns because a child process
118 was found that satisfies the conditions indicated by the arguments \fIidtype\fR
119 and \fIoptions\fR, then the structure pointed to by \fIinfop\fR will be filled
120 by the system with the status of the process. The \fBsi_signo\fR member will
121 always be equal to \fBSIGCHLD\fR.
124 One instance of a \fBSIGCHLD\fR signal is queued for each child process whose
125 status has changed. If \fBwaitid()\fR returns because the status of a child
126 process is available and \fBWNOWAIT\fR was not specified in \fIoptions\fR, any
127 pending \fBSIGCHLD\fR signal associated with the process ID of that child
128 process is discarded. Any other pending \fBSIGCHLD\fR signals remain pending.
132 If \fBwaitid()\fR returns due to a change of state of one of its children and
133 \fBWNOHANG\fR was not used, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
134 returned and \fBerrno\fR is set to indicate the error. If \fBWNOHANG\fR was
135 used, \fB0\fR can be returned (indicating no error); however, no children may
136 have changed state if \fBinfo->si_pid\fR is \fB0\fR.
140 The \fBwaitid()\fR function will fail if:
147 The set of processes specified by \fIidtype\fR and \fIid\fR does not contain
148 any unwaited processes.
157 The \fIinfop\fR argument points to an illegal address.
166 The \fBwaitid()\fR function was interrupted due to the receipt of a signal by
176 An invalid value was specified for \fIoptions\fR, or \fIidtype\fR and \fIid\fR
177 specify an invalid set of processes.
183 With \fIoptions\fR equal to \fBWEXITED\fR | \fBWTRAPPED\fR, \fBwaitid()\fR is
184 equivalent to \fBwaitpid\fR(3C). With \fIidtype\fR equal to \fBP_ALL\fR and
185 \fIoptions\fR equal to \fBWEXITED\fR | \fBWTRAPPED\fR, \fBwaitid()\fR is
186 equivalent to \fBwait\fR(3C).
190 See \fBattributes\fR(5) for descriptions of the following attributes:
198 ATTRIBUTE TYPE ATTRIBUTE VALUE
200 Interface Stability Standard
202 MT-Level Async-Signal-Safe
208 \fBIntro\fR(2), \fBexec\fR(2), \fBexit\fR(2), \fBfork\fR(2), \fBpause\fR(2),
209 \fBsigaction\fR(2), \fBptrace\fR(3C), \fBsignal\fR(3C), \fBsiginfo.h\fR(3HEAD),
210 \fBwait\fR(3C), \fBwaitpid\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)