diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-07-30 07:29:34 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-07-30 07:29:34 +0000 |
commit | 2c448fe6d4182f4b154f941adabfccbdea2936bc (patch) | |
tree | e4e42836fdfd6ffea72c0d6aa86fd2da1105f1cc /bin/ebuild.sh | |
parent | 4928fa94e1f5b247ade11734b432d184a55a322d (diff) | |
download | portage-2c448fe6d4182f4b154f941adabfccbdea2936bc.tar.gz portage-2c448fe6d4182f4b154f941adabfccbdea2936bc.tar.bz2 portage-2c448fe6d4182f4b154f941adabfccbdea2936bc.zip |
Bug #278895 - Make ebuild.sh clean up orphaned processes that may have been
left behind by ebuild phases. This works by using setsid to create a new
login session for the ebuild.sh process, and `kill -s SIGHUP 0` to send
a SIGHUP signal to all processes in the session. The setsid is currently
not done on the python side since that would cause the sandbox process in
the session, and sandbox produces a warning message if it catches a SIGHUP
signal.
svn path=/main/trunk/; revision=13856
Diffstat (limited to 'bin/ebuild.sh')
-rwxr-xr-x | bin/ebuild.sh | 11 |
1 files changed, 11 insertions, 0 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 |