Wait for a specific background process.

Section: Job Control

Wait for background PID

bash
bash
pid=$!
wait "$pid"
Explanation

Capture $! right after starting a job.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Job Control
Run process in background
Start a job in background.
OpenIn sheetbashsame section
List jobs
List shell jobs with process IDs.
OpenIn sheetbashsame section
Resume stopped job in background
Resume a stopped job in background.
OpenIn sheetbashsame section
Bring job to foreground
Resume a job in foreground.
OpenIn sheetbashsame section
Disown background job
Remove a job from shell job table.
OpenIn sheetbashsame section
Send signal to job
Signal a shell job using jobspec.
OpenIn sheetbashsame section