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
| Name | Type | Description |
|---|---|---|
| var | variable name | Writable destination for completion identifier. |
| id | PID or jobspec | Optional 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"