From c950b8f3ca6251bf34d2f19a92cac84de280c710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sat, 30 May 2026 11:12:37 +0200 Subject: [PATCH] build_all: report parallel results in completion order (wait -n -p) Previously the reaping loop waited on jobs in array order, so a finished build's OK/FAILED line was delayed until the loop reached its PID (e.g. appimage done but unreported while flatpak still ran). Use 'wait -n -p' to print each result as soon as that build finishes. Co-Authored-By: Claude Opus 4.8 --- build_all.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/build_all.sh b/build_all.sh index ae390f4..bccc16d 100755 --- a/build_all.sh +++ b/build_all.sh @@ -257,15 +257,21 @@ else # From here until all jobs are reaped, Ctrl+C stops every build tree. trap _interrupt INT TERM + # Reap in completion order (wait -n) so each result prints the moment that + # build finishes, not when its slot comes up in the array. FAILED=() - for pid in "${!PID2NAME[@]}"; do - name="${PID2NAME[$pid]}" - if wait "$pid"; then + remaining=${#PID2NAME[@]} + while [ "$remaining" -gt 0 ]; do + if wait -n -p donepid; then rc=0; else rc=$?; fi + name="${PID2NAME[$donepid]:-}" + [ -z "$name" ] && continue + if [ "$rc" -eq 0 ]; then echo " -> $name: OK" else - echo " -> $name: FAILED (rc=$?)" + echo " -> $name: FAILED (rc=$rc)" FAILED+=("$name") fi + remaining=$((remaining - 1)) done trap - INT TERM