Wait Article Index for
Wait
Articles about
Wait
Website Links For
Wait
 

Information About

Wait




wait is a command which pauses until execution of a Background Process has ended.


USAGE

wait n" class="copylinks" target="_blank">{Link without Title}

Where n is the Pid or Job Number of a currently executing background process (job). If n is not given, the command waits until all jobs known to the invoking shell have terminated.

wait normally returns the exit code of the last job which terminated. It may also return 127 in the event that '''n''' specifies a non-existent job or zero if there were no jobs to wait for.


EXAMPLE

This command can be useful where part of a script can execute in parallel to implement a barrier where an upcoming section depends on the successful completion of the preceding sections.

The following (somewhat contrived) example will fetch the src/ directory from a machine named '''iona''' using Rsync and simultaneously update the libraries on which this program depends, before building the combination.

#!/bin/bash

# Parallel update script which makes use of the wait command

# Update local copy
rsync iona:src/ . &
# Upgrade required libraries, or exit indicating failure if make failed for some reason