wait — Wait for a child process to end

Format

wait [pid|job-id …]

tcsh shell: wait

Description

wait waits for one or more jobs or child processes to complete in the background. If you specify one or more job-id arguments, wait waits for all processes in each job to end. If you specify pid, wait waits for the child process with that process ID (PID) to end. If no child process has that process ID, wait returns immediately.

If you specify neither a pid nor a job-id, wait waits for the process IDs known to the invoking shell to complete.

In the tcsh shell, the shell waits for all background jobs. If the shell is interactive, an interrupt disrupts the wait and cause the shell to print the names and job numbers of all outstanding jobs. See tcsh — Invoke a C shell.

Localization

wait uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Usage notes

wait is a built-in shell command.

Exit values

If one or more arguments (pid or job-id) are specified, the exit status of wait is the exit status of the last argument.

If you specified a job-id that has terminated or is unknown by the invoking shell, an error message and a return code of 127 is returned. If you specified a pid that has terminated or is unknown to the shell, a return code of 127 is returned. If a signal ended the process abnormally, the exit status is a value greater than 128 unique to that signal. Otherwise, possible exit status values are:
0
Successful completion or wait was invoked with no arguments, and all child processes known to the invoking shell have completed.
1–126
An error occurred
127
A specified pid or job-id has terminated or is unknown by the invoking shell

Portability

POSIX.2, X/Open Portability Guide, UNIX systems.

Related information

sleep, tcsh