diff options
author | Bryan Drewery <bryan@shatow.net> | 2014-09-19 09:08:00 +0400 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2014-09-19 09:08:00 +0400 |
commit | 13dadcf04394cc40632d47f5fcb135ed33855c4e (patch) | |
tree | fa7b70b5295a768e68fb06b51807f9f1a3c6fff6 /src/share/poudriere/include/parallel.sh | |
parent | 2184eec4d7529384efab2bce9a5717f247eee17a (diff) |
parallel_run: Delay returning until after running the next child job.
This is needed in case the parent caller is using || to delay errors,
such as is done in the compute_deps code.
Diffstat (limited to 'src/share/poudriere/include/parallel.sh')
-rw-r--r-- | src/share/poudriere/include/parallel.sh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/share/poudriere/include/parallel.sh b/src/share/poudriere/include/parallel.sh index 10278b46..d6b60760 100644 --- a/src/share/poudriere/include/parallel.sh +++ b/src/share/poudriere/include/parallel.sh @@ -200,15 +200,18 @@ parallel_shutdown() { parallel_run() { local cmd="$1" + local ret shift 1 + ret=0 + # Occasionally reap dead children. Don't do this too often or it # becomes a bottleneck. Do it too infrequently and there is a risk # of PID reuse/collision _SHOULD_REAP=$((${_SHOULD_REAP} + 1)) if [ ${_SHOULD_REAP} -eq 16 ]; then _SHOULD_REAP=0 - _reap_children || return $? + _reap_children || ret=$? fi # Only read once all slots are taken up; burst jobs until maxed out. @@ -220,6 +223,8 @@ parallel_run() { [ ${NBPARALLEL} -lt ${PARALLEL_JOBS} ] && NBPARALLEL=$((NBPARALLEL + 1)) PARALLEL_CHILD=1 parallel_exec $cmd "$@" & PARALLEL_PIDS="${PARALLEL_PIDS} $! " + + return ${ret} } nohang() { |