From bf7f890f460cfb8463efe011dd643b3d9e30f8d9 Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Mon, 9 Feb 2026 18:02:33 -0500 Subject: [PATCH] fix: Race condition in validate-examples parallel execution The wait -n + pid array removal was buggy - it removed the first pid from the array when any job finished, not the one that actually completed. This caused the final wait loop to miss some processes. Fix: Use bare 'wait' at the end which waits for ALL background processes, regardless of what's in the pid array. --- scripts/validate-examples.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/validate-examples.sh b/scripts/validate-examples.sh index c5348e9..9eb8f26 100755 --- a/scripts/validate-examples.sh +++ b/scripts/validate-examples.sh @@ -333,12 +333,12 @@ validate_examples_parallel() { fi done - # Wait for ALL remaining jobs to complete - for pid in "${pids[@]}"; do - wait "$pid" 2>/dev/null || true - done + # Wait for ALL background jobs to complete (not just tracked pids) + # Using bare 'wait' ensures we catch all subprocesses, even those + # whose pids were incorrectly removed from the array by wait -n + wait - # Wait a bit more to ensure all file writes are complete + # Extra safety margin for filesystem sync sleep 0.5 # Aggregate results from result files (since subshell variables don't propagate)