wait

NAME

wait - wait for process completion

SYNOPSIS

wait [jobid]

DESCRIPTION

This is a shell built-in command.

The wait(1) command waits for the specified job(s) to finish. The jobid is specified either by the process identifier (ID) of the last process in the command pipeline, or by prefixing the job-number (revealed by the jobs(1) command) with a percent sign (%).

Other special job IDs are:

%+
The most recently stopped job, or, if there are no stopped jobs, the oldest running job.
%%, %
Same as %+.
%-
The job that would be the %+ job, if the latter did not exist.
%n
The job with job number n.
%?string
The job containing the string string (an error occurs if multiple jobs are matched).
%string
The job starting with string string (an error occurs if multiple jobs are matched).

The wait(1) command will return if a signal for which a trap has been set is received, or if a HUP, INT or QUIT signal is received.

If no jobs are specified, wait(1) waits for all currently running jobs (if any) to finish and exits with a zero status. If job monitoring is enabled, the completion status of jobs is printed (this is not the case when jobs are explicitly specified).

DIAGNOSTICS

The wait(1) command exits with the status of the last specified job, unless:

SEE ALSO

sh(1)