Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ wait(2) — HP-UX 6.00

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 − 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 that is 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 it has hit a break point. The wait system call will return prematurely if a signal is received.  If a child or traced 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. The status can be used to differentiate between stopped and terminated processes. If the process is terminated, 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 stopped, the high order 8 bits of the status will contain the number of the signal that caused it to stop and the low order 8 bits will be set equal to 0177. 

If the process terminated because of an exit or _exit call, the low order 8 bits of the status will be zero and the high order 8 bits will contain the low order 8 bits of the argument that the process passed to exit; see exit(2).

If the process terminated because of a signal, the high order 8 bits of the 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, 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 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 will fail if one or more of the following are true:

­[ECHILD] The calling process has no existing unwaited-for child or traced 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 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, 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,  May 11, 2021

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