Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ wait2(2j) — Ultrix-11 3.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exit(2)

fork(2)

sigsys(2j)

wait(2)

wait2(2j)

NAME

wait2 − wait for a process to terminate

SYNTAX

#include <wait.h>

int wait2(&w.w_status, options)
union wait w;
int options;

cc ... −ljobs

DESCRIPTION

The wait2 system call is similar to the standard wait call, but it allow additional options useful with job control.  Both calls return the process ID of a terminated or stopped child process.  The w.w_status and options are described by definitions and macros in the file <wait.h>.  The union, its bitfield definitions, and the associated macros provide convenient and mnemonic access to the word of status returned by a wait2 call.  If the call returns a process ID, several macros are available to interpret the status word returned.  If the process is stopped, WIFSTOPPED(w) is true, and the signal that caused it to stop is w.w_stopsig.  If the process is not stopped (has terminated), WIFEXITED(w) determines whether it terminated by calling an exit call.  If so, the exit code is w.w_retcode.  WIFSIGNALED(w) is true if the process was terminated by a signal.  For further information, see signal(2).  The signal causing termination was w.w_termsig, and w.w_coredump indicates whether a core dump was produced. 

There are two options, which may be combined by a bitwise or of them.  The first is WNOHANG which causes the wait2 to not hang if there are no processes which wish to report status, rather returning a pid of 0 in this case as the result of the wait2.  The second option is WUNTRACED which causes wait2 to return information when children of the current process which are stopped but not traced with the ptrace call because they received a SIGTTIN, SIGTTOU, SIGTSTP or SIGSTOP signal.  For further information, see sigsys(2j). 

RESTRICTIONS

This call is peculiar to this version of UNIX.  The options and specifications of this system call and even the call itself are subject to change.  It may be replaced by other facilities in future versions of the system. 

RETURN VALUE

If there are no children not previously waited for, returns a −1.  If the WNOHANG option is given and if there are no stopped or exited children, returns a 0. 

DIAGNOSTICS

The wait2 call will fail if:

[ECHILD] The calling process has no unwaited-for child processes. 

[EFAULT] The specified w.w_status points to an address outside the process’s allocated address space. 

SEE ALSO

exit(2), fork(2), sigsys(2j), wait(2)

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