Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

break(1sh)

cd(1sh)

chdir(1sh)

continue(1sh)

csh(1csh)

echo(1sh)

eval(1sh)

exec(1sh)

exit(1sh)

export(1sh)

hash(1sh)

login(1)

pwd(1sh)

read(1sh)

readonly(1sh)

return(1sh)

set(1sh)

sh(1sh)

shift(1sh)

test(1sh)

times(1sh)

trap(1sh)

type(1sh)

ulimit(1sh)

umask(1sh)

unset(1sh)

which(1sh)

execve(2)

wait(2)



WAIT(1SH)               COMMAND REFERENCE               WAIT(1SH)



NAME
     wait - await completion of process (sh built-in)

SYNOPSIS
     wait [ n ]

DESCRIPTION
     Wait waits for the specified process to complete and sets
     the exit status to that of the waited-for process.

     If n is not given, all currently active child processes are
     waited for and the exit status is zero.

     Because the wait(2) system call must be executed in the
     parent process, the Shell itself executes wait, without
     creating a new process.

EXAMPLES
     The major use of wait is in the area of multiprogramming at
     the shell level. The following shell script takes each file
     argument and checks it for spelling errors and looks for the
     word UTek (ignoring the case of the letters).  All files are
     processed simultaneously. After all files have been
     processed, a report is generated for those files with
     spelling errors and/or that contain the word UTek.

          #!/bin/sh trap 'rm -f /tmp/speller.*.$$ /tmp/spellgrep.*.$$;exit' 0 1 2
          for i in "$@"
          {
               if test ! -r "$i"
               then
                    echo "$0 : $i : Permission denied."
                    exit 1
               fi
               spell "$i" > /tmp/speller."$i".$$&
               grep -i utek "$i" > /tmp/spellgrep."$i".$$&
          }
          wait
          for i in "$@"
          {
               if test -s /tmp/speller."$i".$$
               then
                    echo "Spelling errors were found in the file $i."
               fi
               set `wc -l /tmp/spellgrep."$i".$$`
               if test $1 -ne 0
               then
                    echo "The word 'utek' was found in the file $i \c"
                    echo "on $1 lines."
               fi
          }
          exit 0



Printed 4/6/89                                                  1





WAIT(1SH)               COMMAND REFERENCE               WAIT(1SH)



     It is important to note that background jobs (those started
     with &) do not have their processes printed by the shell
     unless the shell is interactive. This means that the shell
     programmer does not have to worry about getting rid of these
     messages. This process ID is instead available in the
     variable $!.

RETURN VALUE
     The exit status returned by wait is the maximum of the exit
     statuses returned by all of the waited-for processes.

CAVEATS
     Not all the processes of a three- or more-stage pipeline are
     children of the Shell, and thus cannot be waited for.  (This
     bug does not apply to csh(1csh).)

SEE ALSO
     break(1sh), cd(1sh), chdir(1sh), continue(1sh), csh(1csh),
     echo(1sh), eval(1sh), exec(1sh), exit(1sh), export(1sh),
     hash(1sh), login(1), pwd(1sh), read(1sh), readonly(1sh),
     return(1sh), set(1sh), sh(1sh), shift(1sh), test(1sh),
     times(1sh), trap(1sh), type(1sh), ulimit(1sh), umask(1sh),
     unset(1sh), which(1sh), execve(2), and wait(2).
































Printed 4/6/89                                                  2



%%index%%
na:288,120;
sy:408,148;
de:556,597;
ex:1153,1439;2952,345;
rv:3297,288;
ca:3585,264;
se:3849,903;
%%index%%000000000131

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