Launch a background process and check when it ends
The key is the "wait" command:
#!/bin/bash
/my/process &
/another/process &
wait
echo "All processes done!"
With wait
you can have the granularity you need:
sleep 1 &
PID1=$!
sleep 2 &
PID2=$!
wait $PID1
echo 'PID1 has ended.'
wait
echo 'All background processes have exited.'
Here is one way to do it:
launch backgroundprocess &
PROC_ID=$!
while kill -0 "$PROC_ID" >/dev/null 2>&1; do
echo "PROCESS IS RUNNING"
done
echo "PROCESS TERMINATED"
exit 0