WAIT(2) — HP-UX
NAME
wait − wait for child process to stop or terminate
SYNOPSIS
int wait (stat_loc)
int ∗stat_loc;
int wait ((int ∗)0)
#include <sys/wait.h>
int wait3 (stat_loc, options, (int ∗)0)
int ∗stat_loc;
int options;
DESCRIPTION
Wait suspends the calling process until one of the immediate children terminates or until a child that is being traced stops, because it has hit a break point. The wait system call will return prematurely if a signal is received. If a child process stopped or terminated prior to the call on wait, return is immediate.
If stat_loc (taken as an integer) is non-zero, 16 bits of information called status are stored in the low order 16 bits of the location pointed to by stat_loc. Status can be used to differentiate between stopped and terminated child processes. If the child process is terminated, status identifies the cause of termination and passes useful information to the parent. This is accomplished in the following manner:
If the child process stopped, the high order 8 bits of status will contain the number of the signal that caused the process to stop and the low order 8 bits will be set equal to 0177.
If the child process terminated due to an exit or _exit call, the low order 8 bits of status will be zero and the high order 8 bits will contain the low order 8 bits of the argument that the child process passed to exit; see exit(2).
If the child process terminated due to a signal, the high order 8 bits of status will be zero and the low order 8 bits will contain the number of the signal that caused the termination. In addition, if the low order seventh bit (i.e., bit 0200) is set, a "core image" will have been produced; see signal(2).
If the wait3 variant is used, then there are two options available for modifying the behavior of the system call. They may be combined by oring them together. The first is WNOHANG which prevents wait3 from suspending the calling process even if there are children to wait for. In this case, a value of zero is returned indicating there are no children which have stopped or died. If the second option WUNTRACED is set, then in addition to traced children which are stopped, wait3 will also return information when children of the current process are stopped but not traced (with ptrace(2)) because they received a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal.
The third parameter to wait3 is currently unused and must always be a null pointer.
If a parent process terminates without waiting for its child processes to terminate, the parent process ID of each child process is set to 1. This means the initialization process inherits the child processes.
ERRORS
Wait will fail if one or more of the following are true:
[ECHILD] The calling process has no existing unwaited-for child processes. In this case, wait returns immediately.
[EFAULT] Stat_loc points to an illegal address. The reliable detection of this error will be implementation dependent.
[EINVAL] Wait3 was passed a non-null pointer value for its third argument.
RETURN VALUE
If wait returns due to the receipt of a signal, a value of −1 is returned to the calling process and errno is set to EINTR. If wait returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. If wait3 is called, the WNOHANG option is used, and there are no stopped or terminated children, then a value of zero is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
WARNINGS
The behavior of wait is affected by setting the SIGCLD signal to SIG_IGN. Check all references to signal(2) for appropriateness on systems that support sigvector(2). Sigvector(2) can affect that behavior described on this page. See WARNINGS on signal(2).
HARDWARE DEPENDENCIES
Series 200, 300, 500
_Wait3_ is not supported.
AUTHOR
Wait and wait3 were developed by the Hewlett-Packard Company, AT&T Bell Laboratories, and the University of California, Berkeley California, Computer Science Division, Department of Electrical Engineering and Computer Science.
SEE ALSO
Exit conditions ($?) in sh(1), exec(2), exit(2), fork(2), pause(2), ptrace(2), signal(2).
Hewlett-Packard Company — Version B.1, April 12, 1993