multibuild.eclass: Reap stray subjobs before exiting sub-phase
authorMichał Górny <mgorny@gentoo.org>
Thu, 23 Mar 2017 17:52:12 +0000 (18:52 +0100)
committerMichał Górny <mgorny@gentoo.org>
Fri, 14 Apr 2017 16:27:52 +0000 (18:27 +0200)
Alike the PMS-defined phases, sub-phases do not support leaving jobs
behind. To avoid leaving something accidentally, make sure to reap all
jobs (i.e. wait) post running the command. Warn if any stray processes
are found since that indicates a bug in ebuild.

eclass/multibuild.eclass

index 0f89e4ec0b83a21a2c32cdfd708ff64710aa1554..a29218d8d84078250e1cbee6ed82e746fb17c3b8 100644 (file)
@@ -125,6 +125,18 @@ multibuild_foreach_variant() {
                _multibuild_run "${@}" \
                        > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1
                lret=${?}
+
+               # make sure no processes are left over
+               local leftovers=
+               while :; do
+                       wait -n
+                       [[ ${?} -eq 127 ]] && break || leftovers=1
+               done
+
+               if [[ ${leftovers} ]]; then
+                       ewarn "The multibuild function has left one or more processes running"
+                       ewarn "in the background. Please report a bug."
+               fi
        done
        [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret}