Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ wait(2) — HP-UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sh(1)

exec(2)

exit(2)

fork(2)

pause(2)

ptrace(2)

signal(2)

WAIT(2)  —  HP-UX

NAME

wait, wait3 − wait for child or traced 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 process being traced (either a child or a process attached by the ptrace(2) request PT_ATTACH (see the DEPENDENCIES section of ptrace(2)) stops, because that traced process has hit a break point. The wait system call returns prematurely if a signal is received.  If a child or traced process stops or terminates prior to the call on wait, return is immediate.

If stat_loc (taken as an integer) is non-zero, 16 bits of status information are stored in the low-order 16 bits of the location pointed to by stat_loc. The status can be used to differentiate between stopped and terminated processes. If the process terminates, the status identifies the cause of termination and passes useful information to the calling process.  This is accomplished in the following manner:

If the process stops, the high-order 8 bits of the status contain the number of the signal that caused it to stop and the low-order 8 bits are set equal to 0177. 

If the process terminates because of an exit(2) or _exit system call, the low-order 8 bits of the status are zero and the high-order 8 bits contain the low-order 8 bits of the argument that the process passed to exit (see exit(2)).

If the process terminates because of a signal, the high-order 8 bits of the status are zero and the low-order 8 bits contain the number of the signal that caused the termination.  In addition, if the low-order seventh bit (that is, bit 0200) is set, a "core image" was produced (see signal(2)).

If the wait3 variant is used, two options are available for modifying the behavior of the system call.  They may be combined by computing their logical OR.  The first is WNOHANG, which prevents wait3 from suspending the calling process even if there are processes to wait for.  In this case, a value of zero is returned indicating there are no processes that have stopped or died.  If the second option WUNTRACED is set, wait3 will return information on traced processes that are stopped, and on children of the current process that 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 fails if one or more of the following is true:

­[ECHILD] The calling process has no existing child or traced processes to wait for.  In this case, wait returns immediately. 

­[EFAULT] Stat_loc points to an illegal address.  The reliable detection of this error is 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 or traced process, the process ID of that process is returned to the calling process.  If wait3 is called, the WNOHANG option is used, and there are no stopped or terminated child or traced processes, 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 the behavior described on this page. See WARNINGS on signal(2).

DEPENDENCIES

Series 300
The WUNTRACED flag to wait3 is not supported, because job control and the associated signals are not supported. 

AUTHOR

Wait and wait3 were developed by HP, AT&T, and the University of California, Berkeley. 

SEE ALSO

Exit conditions ($?) in sh(1), exec(2), exit(2), fork(2), pause(2), ptrace(2), signal(2). 

Hewlett-Packard Company  —  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026