Skip to content

Commit

Permalink
better wait logic - 2 (sleeps)
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Oct 14, 2024
1 parent cb8b54f commit 1b283bd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions resources/launch_scripts/local-scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ find_finished_pid() {
# Loop over the number of background tasks -- each time, we'll wait on the FIRST to finish
pids=("${!pidmap[@]}") # get keys
for ((i = 0; i < ${#pids[@]}; i++)); do
sleep 10
set -x
wait -n # wait for the FIRST to finish
exit_status=$?
set +x
sleep 5 # for our logs

# find the finished process PID by checking jobs
running_pids=($(jobs -pr))
Expand All @@ -167,8 +169,10 @@ for ((i = 0; i < ${#pids[@]}; i++)); do
echo "ERROR: A process exited with status $exit_status. Exiting and killing remaining processes."
# Kill all remaining background processes
for pid in "${pids[@]}"; do
sleep 1
kill "$pid" 2>/dev/null
done
sleep 10 # for proc logs
exit 1
fi
done
Expand Down

0 comments on commit 1b283bd

Please sign in to comment.