Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

wait (command)

From Wikipedia, the free encyclopedia
Command which pauses until execution of a background process has ended
This article is about the Unix command. For other uses, seeWait.
wait
DeveloperAT&T Bell Laboratories
Initial releaseNovember 1973; 52 years ago (1973-11)
Operating systemUnix andUnix-like
TypeCommand

InUnixshells,wait is acommand which pauses until execution of abackground process has ended.

Usage

[edit]
wait[n...]

wheren... is a list ofpids orjob IDs of a currently executing background process (job). If no ids are provided, the command waits until all jobs known to the invoking shell have terminated.

wait normally returns theexit status of the last job which terminated. It may also return 127 in the event thatn specifies a non-existent job or zero if there were no jobs to wait for.

Becausewait needs to be aware of the job table of the current shell execution environment. Under thePOSIX specifications it is required to be ashell builtin.[1]

Example

[edit]

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 example will fetch thesrc/ directory from a machine namediona usingrsync and simultaneously update the libraries on which this program depends, before building the combination.

#!/usr/bin/env bash# Parallel update script which makes use of the wait command# Update local copyrsynciona:src/.&# Upgrade required libraries, or exit indicating failure if make failed for some reasonmake-Clib||exit1# Wait for rsync to terminate (may have already happened) and finish the jobwaitmake

Wait for specified job control id number:

$ls-R/>/dev/null2>&1&# start any long running background process[2]1986$wait%2# waits for background job number 2 to terminate, then returns

See also

[edit]

References

[edit]
  1. ^"The Open Group Base Specifications Issue 8". The Open Group. 2024.Archived from the original on May 18, 2025. RetrievedMay 14, 2025.

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
Retrieved from "https://en.wikipedia.org/w/index.php?title=Wait_(command)&oldid=1336333903"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp