From 22f3f0a604b89334dcee15be6394ddf97fa32b0d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 30 Jul 2009 21:29:45 +0000 Subject: Move the setsid code (from bug #278895) as early as possible. svn path=/main/trunk/; revision=13861 --- bin/ebuild.sh | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'bin') diff --git a/bin/ebuild.sh b/bin/ebuild.sh index bd32f85ff..794738f16 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -18,6 +18,23 @@ if [ -n "${PORTAGE_ROOTPATH}" ] ; then unset PORTAGE_ROOTPATH fi +ROOTPATH=${ROOTPATH##:} +ROOTPATH=${ROOTPATH%%:} +PREROOTPATH=${PREROOTPATH##:} +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 $1 && $1 != 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" "$@" + fi +fi +[[ $PORTAGE_SETSID = 1 ]] && trap 'trap : SIGHUP ; kill -s SIGHUP 0 ;' EXIT + # These two functions wrap sourcing and calling respectively. At present they # perform a qa check to make sure eclasses and ebuilds and profiles don't mess # with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them @@ -64,24 +81,6 @@ unalias -a # Unset some variables that break things. unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE -ROOTPATH=${ROOTPATH##:} -ROOTPATH=${ROOTPATH%%:} -PREROOTPATH=${PREROOTPATH##:} -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 -- cgit v1.2.3-1-g7c22