Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2014-04-17 02:19:19 +0400
committerBryan Drewery <bryan@shatow.net>2014-04-17 02:19:19 +0400
commit5f28db9c3d2546745a7f8a4ca648538510916fd1 (patch)
tree7bc5e22a8b52fd50c18a1f1d1d9e8f4279f65b8d
parent28e3f3e71af8b940e96948e9707d23670c9f4964 (diff)
parallel.sh: Make this more friendly to out-of-tree use
-rw-r--r--src/share/poudriere/include/parallel.sh21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/share/poudriere/include/parallel.sh b/src/share/poudriere/include/parallel.sh
index 05e59196..037d3c80 100644
--- a/src/share/poudriere/include/parallel.sh
+++ b/src/share/poudriere/include/parallel.sh
@@ -95,7 +95,7 @@ parallel_exec() {
${cmd} "$@"
)
ret=$?
- echo >&6 || :
+ echo >&9 || :
exit ${ret}
# set -e will be restored by 'local -'
}
@@ -109,10 +109,11 @@ parallel_start() {
fifo=$(mktemp -ut parallel)
fi
mkfifo ${fifo}
- exec 6<> ${fifo}
+ exec 9<> ${fifo}
rm -f ${fifo}
export NBPARALLEL=0
export PARALLEL_PIDS=""
+ : ${PARALLEL_JOBS:=$(sysctl -n hw.ncpu)}
_SHOULD_REAP=0
}
@@ -153,8 +154,8 @@ parallel_stop() {
_wait ${PARALLEL_PIDS} || ret=$?
fi
- exec 6<&-
- exec 6>&-
+ exec 9<&-
+ exec 9>&-
unset PARALLEL_PIDS
unset NBPARALLEL
@@ -183,7 +184,7 @@ parallel_run() {
# Only read once all slots are taken up; burst jobs until maxed out.
# NBPARALLEL is never decreased and only inreased until maxed.
if [ ${NBPARALLEL} -eq ${PARALLEL_JOBS} ]; then
- unset a; until trappedinfo=; read a <&6 || [ -z "$trappedinfo" ]; do :; done
+ unset a; until trappedinfo=; read a <&9 || [ -z "$trappedinfo" ]; do :; done
fi
[ ${NBPARALLEL} -lt ${PARALLEL_JOBS} ] && NBPARALLEL=$((NBPARALLEL + 1))
@@ -214,7 +215,7 @@ nohang() {
fifo=$(mktemp -ut nohang)
mkfifo ${fifo}
- exec 7<> ${fifo}
+ exec 8<> ${fifo}
rm -f ${fifo}
starttime=$(date +%s)
@@ -224,7 +225,7 @@ nohang() {
local ret=0
"$@" || ret=1
# Notify the pipe the command is done
- echo done >&7 2>/dev/null || :
+ echo done >&8 2>/dev/null || :
exit $ret
) &
childpid=$!
@@ -254,7 +255,7 @@ nohang() {
# This is done instead of a 'sleep' as it should recognize
# the command has completed right away instead of waiting
# on the 'sleep' to finish
- unset n; until trappedinfo=; read -t $read_timeout n <&7 ||
+ unset n; until trappedinfo=; read -t $read_timeout n <&8 ||
[ -z "$trappedinfo" ]; do :; done
if [ "${n}" = "done" ]; then
_wait $childpid || ret=1
@@ -263,8 +264,8 @@ nohang() {
# Not done, was a timeout, check the log time
done
- exec 7<&-
- exec 7>&-
+ exec 8<&-
+ exec 8>&-
rm -f ${pidfile}