148 lines
2.8 KiB
Groff
148 lines
2.8 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g2.waitid @(#)waitid 40.13 of 1/3/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} waitid 2 "" "\&"
|
|
.if \nX=1 .ds x} waitid 2 ""
|
|
.if \nX=2 .ds x} waitid 2 "" "\&"
|
|
.if \nX=3 .ds x} waitid "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4waitid\f1 \- wait for child process to change state
|
|
.SH SYNOPSIS
|
|
.nf
|
|
\f4#include <sys/types.h>\f1\f4 \f1
|
|
\f4#include <wait.h>\f1
|
|
.sp .6v
|
|
\f4int waitid(idtype_t idtype, id_t id, siginfo_t *infop, \c
|
|
int options);\f1
|
|
.fi
|
|
.SH DESCRIPTION
|
|
\f4waitid\f1
|
|
suspends the calling process until
|
|
one of its children changes state.
|
|
It records the current state of a child in the
|
|
structure pointed to by \f2infop\f1.
|
|
If a child process changed state prior to the call to
|
|
\f4waitid\f1,
|
|
\f4waitid\f1
|
|
returns immediately.
|
|
.PP
|
|
The
|
|
.I idtype
|
|
and
|
|
.I id
|
|
arguments specify which children
|
|
\f4waitid\f1
|
|
is to wait for.
|
|
.IP
|
|
If
|
|
\f2idtype\f1
|
|
is \f4P_PID\f1,
|
|
\f4waitid\f1
|
|
waits for the child with a process
|
|
ID
|
|
equal to
|
|
\f4(pid_t) \f1\f2id\f1.
|
|
.IP
|
|
If
|
|
\f2idtype\f1
|
|
is \f4P_PGID\fP,
|
|
\f4waitid\f1
|
|
waits for any child with a process group
|
|
ID
|
|
equal to
|
|
\f4(pid_t)\f1\f2id\f1.
|
|
.IP
|
|
If
|
|
\f2idtype\f1
|
|
is \f4P_ALL\fP,
|
|
\f4waitid\f1
|
|
waits for any children and
|
|
\f2id\f1
|
|
is ignored.
|
|
.PP
|
|
The
|
|
\f2options\f1
|
|
argument is used to specify which state changes
|
|
\f2waitid\f1
|
|
is to wait for.
|
|
It is formed by an
|
|
OR
|
|
of any of the following flags:
|
|
.TP 15
|
|
\f4WEXITED\fP
|
|
Wait for process(es) to exit.
|
|
.TP
|
|
\f4WTRAPPED\fP
|
|
Wait for traced process(es) to become trapped or reach a breakpoint
|
|
(see \f4ptrace\f1(2)).
|
|
.TP
|
|
\f4WSTOPPED\fP
|
|
Wait for and return the process status of any child that has
|
|
stopped upon receipt of a signal.
|
|
.TP
|
|
\f4WCONTINUED\fP
|
|
Return the status for any child that was stopped and has been continued.
|
|
.TP
|
|
\f4WNOHANG\fP
|
|
Return immediately.
|
|
.TP
|
|
\f4WNOWAIT\fP
|
|
Keep the process in a waitable state.
|
|
.PP
|
|
\f2infop\f1
|
|
must point to a
|
|
\f4siginfo_t\f1
|
|
structure, as defined in
|
|
\f4siginfo\f1(5).
|
|
\f4siginfo_t\f1
|
|
is filled in by the system with the status of the process being
|
|
waited for.
|
|
.PP
|
|
\f4waitid\f1 fails if one or more of the following is true.
|
|
.TP 15
|
|
\f4EFAULT\f1
|
|
\f2infop\f1
|
|
points to an invalid address.
|
|
.TP
|
|
\f4EINTR\f1
|
|
\f4waitid\f1
|
|
was interrupted due to the receipt of a signal by the calling process.
|
|
.TP
|
|
\f4EINVAL\f1
|
|
An invalid value was specified for
|
|
\f2options\f1.
|
|
.TP
|
|
\f4EINVAL\f1
|
|
\f2idtype\f1
|
|
and
|
|
\f2id\f1
|
|
specify an invalid set of processes.
|
|
.TP
|
|
\f4ECHILD\f1
|
|
The set of processes specified by
|
|
\f2idtype\f1
|
|
and
|
|
\f2id\f1
|
|
does not contain any unwaited-for processes.
|
|
.SH DIAGNOSTICS
|
|
If \f4waitid\f1
|
|
returns due to a change of state of one of its children, a value of 0
|
|
is returned.
|
|
Otherwise, a value of \-1 is returned and
|
|
\f4errno\f1
|
|
is set to indicate the error.
|
|
.SH "SEE ALSO"
|
|
exec(2),
|
|
exit(2),
|
|
fork(2),
|
|
intro(2),
|
|
pause(2),
|
|
ptrace(2),
|
|
sigaction(2),
|
|
signal(2),
|
|
wait(2),
|
|
siginfo(5)
|