3/15/72                                                 WAIT (II)

NAME            wait  --  wait for process to die

SYNOPSIS        sys wait  / wait = 7.

                (process ID in r0)

                (termination status/user status in MQ)

DESCRIPTION     wait causes its caller to delay until one of its

                child processes terminates.  If any child has al-

                ready died, return is immediate; if there are no

                children, return is immediate with the error bit

                set.  In the case of several children several

                waits are needed to learn of all the deaths.

                If the error bit is not set on return, the MQ

                high byte contains the low byte of the child pro-

                cess r0 when it terminated.  The MQ low byte con-

                tains the termination status of the process from

                the following list:

                   0    exit

                   1    bus error

                   2    trace trap

                   3    illegal instruction

                   4    IOT trap

                   5    power fail trap

                   6    EMT trap

                   7    bad system call

                   8    quit

                   9    interrupt

                   10   kill (see kill(II))

                   +16  core image produced

FILES           --

SEE ALSO        exit(II), fork(II)

DIAGNOSTICS     error bit (c-bit) on if no children not previ-

                ously waited for.

BUGS            A child which dies but is never waited for is not

                really gone in that it still consumes disk swap

                and system table space.  This can make it impos-

                sible to create new processes.  The bug can be

                noticed when several "&" separators are given to

                the shell not followed by a command without an

                ampersand.  Ordinarily things clean themselves up

                when an ordinary command is typed, but is possi-

                ble to get into a situation in which no commands

                are accepted, so no waits are done; the system is

                then hung.

                The fix, probably, is to have a new kind of fork

                which creates a process for which no wait is nec-

                essary (or possible); also to limit the number of

                active or inactive descendants allowed to a pro-


OWNER           ken, dmr