summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/ebuild.sh11
-rwxr-xr-xbin/isolated-functions.sh3
-rw-r--r--pym/portage/__init__.py1
3 files changed, 14 insertions, 1 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index a20f8d4c9..bd32f85ff 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -71,6 +71,17 @@ PREROOTPATH=${PREROOTPATH%%:}
PATH=$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin${ROOTPATH:+:}$ROOTPATH
export PATH
+if [[ -z $PORTAGE_SETSID && \
+ -n $EBUILD_SH_ARGS && $EBUILD_SH_ARGS != depend ]] ; then
+ if type -P setsid >/dev/null ; then
+ # Use setsid to create a new login session so that we can use SIGHUP
+ # to ensure that no orphaned subprocesses are left running.
+ export PORTAGE_SETSID=1
+ exec setsid "$PORTAGE_BIN_PATH/ebuild.sh" $EBUILD_SH_ARGS
+ fi
+fi
+trap '[[ $PORTAGE_SETSID = 1 ]] && { trap : SIGHUP ; kill -s SIGHUP 0 ; }' EXIT
+
source "${PORTAGE_BIN_PATH}/isolated-functions.sh" &>/dev/null
# Set IMAGE for minimal backward compatibility with
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 8a7f899b9..8bc6f17fc 100755
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -536,7 +536,8 @@ save_ebuild_env() {
PORTAGE_DEPCACHEDIR PORTAGE_GID PORTAGE_INST_GID \
PORTAGE_INST_UID PORTAGE_LOG_FILE PORTAGE_MASTER_PID \
PORTAGE_QUIET \
- PORTAGE_REPO_NAME PORTAGE_RESTRICT PORTAGE_UPDATE_ENV \
+ PORTAGE_REPO_NAME PORTAGE_RESTRICT \
+ PORTAGE_SETSID PORTAGE_UPDATE_ENV \
PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTDIR \
PORTDIR_OVERLAY ${!PORTAGE_SANDBOX_*} PREROOTPATH \
PROFILE_PATHS PWORKDIR QA_INTERCEPTORS \
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d897af0e8..0e279c433 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1048,6 +1048,7 @@ class config(object):
"EBUILD_PHASE", "EMERGE_FROM", "HOMEPAGE", "INHERITED", "IUSE",
"KEYWORDS", "LICENSE", "PDEPEND", "PF", "PKGUSE",
"PORTAGE_CONFIGROOT", "PORTAGE_IUSE", "PORTAGE_REPO_NAME",
+ "PORTAGE_SETSID",
"PORTAGE_USE", "PROPERTIES", "PROVIDE", "RDEPEND", "RESTRICT",
"ROOT", "SLOT", "SRC_URI"
]