builtin

wait -p

Assign the completed identifier to var, initially unset. Inspect it before interpreting a nonzero result. Supported by the tested Bash 5.2.

Formal Syntax & Structure

bash syntaxbash
wait -n -p var [id ...]

Parameters & Attributes

NameTypeDescription
varvariable nameWritable destination for completion identifier.
idPID or jobspecOptional eligible children.

Return Value

exit status

Assign the completed identifier to var, initially unset. Inspect it before interpreting a nonzero result. Supported by the tested Bash 5.2.

Working Example

Example Snippetbash
( sleep 0.3; exit 6 ) &pid=$!wait -n -p finished "$pid"rc=$?[[ $finished == "$pid" ]] || exit 1printf 'matched status=%s\n' "$rc"
Bash Reference