buildsystem: parallel pid cleanup

This commit is contained in:
MilhouseVH 2019-02-28 06:19:13 +00:00
parent 64bc8c2ab5
commit ad938672b2
2 changed files with 20 additions and 9 deletions

View File

@ -61,7 +61,7 @@ package_worker() {
. config/options "${pkgname}"
[ ! -f "${THREAD_CONTROL}/pid" ] && echo "${PARALLEL_PID}" >"${THREAD_CONTROL}/pid"
[ ! -f "${THREAD_CONTROL}/parallel.pid" ] && echo "${PARALLEL_PID}" >"${THREAD_CONTROL}/parallel.pid"
${SCRIPTS}/${task} ${pkgname} 2>&1 && result=0 || result=1
@ -141,7 +141,7 @@ EOF
export -f package_worker
start_multithread_build() {
local singlethread buildopts
local singlethread buildopts result=0
# init thread control folder
rm -rf "${THREAD_CONTROL}"
@ -174,12 +174,18 @@ start_multithread_build() {
cat ${_CACHE_PACKAGE_GLOBAL} ${_CACHE_PACKAGE_LOCAL} | \
${TOOLCHAIN}/bin/parallel --plain --no-notice --max-args 30 --halt now,fail=1 json_worker | \
${SCRIPTS}/genbuildplan.py --no-reorder --show-wants --build ${@} > "${THREAD_CONTROL}"/plan || return
${SCRIPTS}/genbuildplan.py --no-reorder --show-wants --build ${@} > "${THREAD_CONTROL}"/plan || result=1
cat "${THREAD_CONTROL}"/plan | awk '{print $1 " " $2}' | \
MTBUILDSTART=$(date +%s) MTWITHLOCKS=yes ${TOOLCHAIN}/bin/parallel \
--plain --no-notice --max-procs ${THREADCOUNT} --joblog="${THREAD_CONTROL}/joblog" --plus ${buildopts} \
package_worker {%} {#} {##} {} || return
if [ ${result} -eq 0 ]; then
cat "${THREAD_CONTROL}"/plan | awk '{print $1 " " $2}' | \
MTBUILDSTART=$(date +%s) MTWITHLOCKS=yes ${TOOLCHAIN}/bin/parallel \
--plain --no-notice --max-procs ${THREADCOUNT} --joblog="${THREAD_CONTROL}/joblog" --plus ${buildopts} \
package_worker {%} {#} {##} {} || result=1
rm -f "${THREAD_CONTROL}/parallel.pid"
fi
set +o pipefail
return ${result}
}

View File

@ -10,11 +10,16 @@ if [ -n "${PROJECT}" -a "$1" != "auto" ]; then
fi
_find_latest_tcdir() {
local IFS=$'\n'
if [ -n "${THREAD_CONTROL}" ]; then
echo "${THREAD_CONTROL}"
else
ls -1tdr "${PWD}"/build.*/.threads 2>/dev/null | tail -1
for dir in $(ls -1td "${PWD}"/build.*/.threads 2>/dev/null); do
[ -f "${dir}/parallel.pid" ] && echo "${dir}" && break
done
fi
return 0
}
while [ : ]; do
@ -24,7 +29,7 @@ while [ : ]; do
tcdir="$(_find_latest_tcdir)"
if [ -n "${tcdir}" ]; then
pid="$(cat "${tcdir}/pid" 2>/dev/null || true)"
pid="$(cat "${tcdir}/parallel.pid" 2>/dev/null || true)"
[ -n "${pid}" ] && ps -p ${pid} &>/dev/null && break
fi