Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exec(2)

exit(2)

fork(2)

intro(2)

pause(2)

ptrace(2)

signal(2)

WAIT(2)                              SysV                              WAIT(2)



NAME
     wait - wait for child process to stop or terminate

SYNOPSIS
     int wait (stat_loc)
     int *stat_loc;

DESCRIPTION
     wait suspends the calling process until until one of the immediate
     children terminates or until a child that is being traced reaches a break
     point and stops.  The wait system call will return prematurely if a
     signal is received.  If a child process stopped or terminated prior the
     call to wait, it returns immediately.

     If stat_loc is nonzero, 16 bits of "status" information are stored in the
     low-order 16 bits of the location pointed to by stat_loc.  This status
     information can be used to differentiate between stopped and terminated
     child processes, and, when a child process has terminated, to identify
     the cause of termination and pass 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 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 (that is, bit 200) is set, a process dump ("core
        image" on other systems) will have been produced (see signal(2)).  Use
        tb(1) to examine a process dump.

     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 (see
     intro(2)).

ERRORS
     wait will fail and return immediately if the following is true:

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

SEE ALSO
     exec(2), exit(2), fork(2), intro(2), pause(2), ptrace(2), signal(2).

DIAGNOSTICS
     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.  Otherwise, a value of -1 is returned
     and errno is set to indicate the error.

WARNING
     wait fails and its actions are undefined if stat_loc points to an invalid
     address.

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