builtin
Bash wait
Wait for the specified child and return its completion status; save the PID at launch.
Formal Syntax & Structure
bash syntaxbash
wait [pid ...]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| pid | integer | Child process ID. |
Return Value
exit status
Wait for the specified child and return its completion status; save the PID at launch.
Working Example
Example Snippetbash
coproc WORKER { IFS= read -r -t 2 request || exit 2 printf 'reply:%s\n' "$request" IFS= read -r -t 2 ack || exit 3 exit 7}pid=$WORKER_PIDout=${WORKER[0]}in=${WORKER[1]}printf '%s\n' 'daily report' >&"$in"IFS= read -r -t 2 reply <&"$out" || exit 4printf '%s\n' "$reply"printf 'done\n' >&"$in"wait "$pid"printf 'worker status=%s\n' "$?"