wait4(2) DG/UX 4.30 wait4(2)
NAME
wait4 - Wait for the specified child process to stop or
terminate.
SYNOPSIS
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
int wait4 (child_pid,wait_status, options, rusage)
int child_pid;
union wait * wait_status;
int options;
struct rusage * rusage;
PARAMETERS
child_pid The process id for the child process that we
are waiting on.
wait_status NULL or address of a status word.
options Modifications to the action of wait3.
rusage NULL or address of a resource usage
structure.
DESCRIPTION
Wait4 suspends the calling process until the specified child
process stops or terminates, then reports the identity,
status, and resource usage of the child process to the
calling process.
* A process ("stops") when it is being traced (see
ptrace) and either hits a break point or receives a
signal that is set to be caught.
* A process ("terminates") when it calls exit either
directly or due to the receipt of a signal that causes
the process to terminate.
* A process that has terminated, but whose status has not
been reported on by wait may consume system resources.
The wait operation ("cleans-up") the terminated process
and recovers remaining system resources.
The status of the child process is optionally obtained by
the <wait_status> parameter. If <wait_status> is NULL,
status information is not returned. Otherwise, 16 bits of
status information are stored in the low-order 16 bits of
the location pointed to by <wait_status>. <wait_status> can
be used to determine the termination cause. See wait().
Licensed material--property of copyright holder(s) Page 1
wait4(2) DG/UX 4.30 wait4(2)
A summary of the resources used by a child process that has
terminated is obtained by the <rusage> parameter. If
<rusage> is NULL, a summary is not returned. Otherwise,
summary information is stored in the location pointed to by
<rusage>.
Wait4() is identical to wait3() except that it waits only on
one specified child. Siblings of the specified children are
ignored. If the caller specifies <child_pid> as zero,
wait4() behaves identically to wait3().
The action taken by wait4 may be modified by setting bits in
the <options> parameter as follows.
* The WNOHANG bit specifies that the calling process
should not be suspended by wait4.
* A process that is not being traced may be stopped by
the SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signals. The
WUNTRACED bit specifies that the status of all stopped
child processes should be reported, not just those
being traced.
If a parent process terminates without waiting for its child
processes to terminate, a special system process inherits
the child processes.
If an error occurs, wait4 will not clean-up any process and
the values of <status> and <rusage> are undefined.
Wait4() is automatically restarted when a process receives a
signal while awaiting the termination of a child process.
ACCESS CONTROL
None.
RETURN VALUE
<child-process-id>
Completed successfully.
0 The WNOHANG bit in <options> was set and the
calling process would otherwise have been
suspended by wait3.
-1 An error occurred. Errno is set to indicate
the error.
EXCEPTIONS
Errno may be set to one of the following error codes:
ECHILD The calling process has no child processes.
This condition implies that the calling
Licensed material--property of copyright holder(s) Page 2
wait4(2) DG/UX 4.30 wait4(2)
process was not suspended by wait3.
EFAULT The <status> or <rusage> arguments point to
an illegal address. This condition implies
that the calling process was not suspended by
wait3.
SEE ALSO
The related system calls: exec, exit, fork, ptrace,
sigpause, sigvec, wait, wait3.
STANDARDS
When using m88kbcs as the Software Development Environment
target, the wait4 function will be an incomplete emulation
of Berkeley semantics. Since we are using BCS system calls,
resource usage information is not available. If rusage is
non-NULL, wait4() will fail with errno set to EINVAL.
Licensed material--property of copyright holder(s) Page 3