Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ wait(1) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ksh(1)

sh(1)

wait(1)                                                             wait(1)

NAME
     wait - wait for background processes to terminate

SYNOPSIS
     wait[ processID]

DESCRIPTION
     The shell built-in wait causes the shell to wait

     -  until a previously started background process is complete (if you
        call wait with the required process ID), or

     -  until all previously started background processes terminate (if you
        call wait without arguments).

     When a command is run in the background (with &), the interactive
     shell does not normally wait for it to finish before prompting you for
     a new command. By contrast, if a command is started as a foreground
     process, the shell will always wait for it.

     This also applies with respect to shell scripts. Thus, if a script
     contains a command that is to process the output of a previously
     started background command, wait can be used to ensure that the back-
     ground command terminates first.

     If the error message

     fork failed - too many processes

     appears when you try to run a process in the background, you may be
     able to lessen the system load by running wait. If this has no effect,
     it may be that the system table is full or that there are too many
     active foreground processes.

     Note:  If a pipeline has 3 or more stages, the shell groups processes
            into pairs and spawns a process to control each pair. Hence the
            original processes are not child processes of the shell. wait
            cannot wait for processes which are not children of the shell.

OPERANDS
     processID
          Process identification number of the background process whose
          completion is to be waited for by the shell.

          In the Bourne shell only one process ID may be specified. If more
          than one process ID is given in the command line, wait will only
          consider the first one and will ignore the rest without issuing
          an error message.

          The exit status returned by wait is that of the specified back-
          ground process. If the process you specify is not active, wait
          behaves as it does if you do not specify a PID (see EXIT STATUS).



Page 1                       Reliant UNIX 5.44                Printed 11/98

wait(1)                                                             wait(1)

          The shell always assigns the process ID of the last command run
          in the background to the ! (exclamation point) variable. The con-
          tents of this variable can be accessed with $!.

          processID not specified:

          wait waits for all your shell's currently active background
          processes to complete and returns an exit status of 0.

EXIT STATUS
     If wait was called with no arguments, the exit status is always 0.

     If you call wait with a process ID, the exit status returned by wait
     is that of the background process selected with the given process ID.

LOCALE
     The LCMESSAGES environment variable governs the language in which
     message texts are displayed. If LCMESSAGES is undefined or is defined
     as the null string, it defaults to the value of LANG. If LANG is like-
     wise undefined or null, the system acts as if it were not internation-
     alized.

     The LCALL environment variable governs the entire locale. LCALL
     takes precedence over all the other environment variables which affect
     internationalization.

EXAMPLES
     Example 1

     The shell is to wait for an active background process:

     $ find / -name tst -print 2>/dev/null &
     3456
     $ wait 3456
     home/martin/PASCAL/tst
     ...

     Example 2

     The shell script patience illustrates how to wait for a specific back-
     ground command to terminate. The contents of this shell script are as
     follows:

     : Invocation with sh patience
     sort list > sorted &
     pid1=$!
     tar cvf /dev/dsk/f0t /home/anna &
     pid2=$!
     ...
     wait $pid1
     pg sorted



Page 2                       Reliant UNIX 5.44                Printed 11/98

wait(1)                                                             wait(1)

     The process IDs of the two background command are stored in the vari-
     ables pid1 and pid2, respectively. These process IDs are thus avail-
     able for future use, as the ! variable always holds the process ID of
     the last background command started.

     The wait command causes the script to wait for the sort command to
     complete before displaying the contents of sorted with the pg command.

NOTES
     Some differences in behavior may occur when using wait, depending on
     which shell is being used. The possible differences are not described
     specifically.

SEE ALSO
     ksh(1), sh(1).







































Page 3                       Reliant UNIX 5.44                Printed 11/98

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