Skip to content

Commit

Permalink
scripts/make.sh: Fix parallel job creation
Browse files Browse the repository at this point in the history
Use `$!` to track children processes, rather than `jobs -rp`.
  • Loading branch information
drinkcat committed Feb 26, 2016
1 parent 5e3d1e3 commit 4c70562
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,18 @@ do
LFILES="$LFILES $OUT"
[ "$OUT" -nt "$i" ] && continue
do_loudly $BUILD -c $i -o $OUT &
PENDING="$PENDING$! "

# ratelimit to $CPUS many parallel jobs, detecting errors

while true
do
PENDING="$(echo $PENDING $(jobs -rp) | tr ' ' '\n' | sort -u)"
[ $(echo -n "$PENDING" | wc -l) -lt "$CPUS" ] && break;
[ $(echo -n "$PENDING" | tr ' ' '\n' | wc -l) -lt "$CPUS" ] && break;

wait $(echo "$PENDING" | head -n 1)
PID="${PENDING%% *}"
wait "$PID"
DONE=$(($DONE+$?))
PENDING="$(echo "$PENDING" | tail -n +2)"
PENDING="${PENDING#$PID }"
done
[ $DONE -ne 0 ] && break
done
Expand Down

0 comments on commit 4c70562

Please sign in to comment.