Move the setsid code (from bug #278895) as early as possible.
authorZac Medico <zmedico@gentoo.org>
Thu, 30 Jul 2009 21:29:45 +0000 (21:29 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 30 Jul 2009 21:29:45 +0000 (21:29 -0000)
svn path=/main/trunk/; revision=13861

bin/ebuild.sh

index bd32f85ff1829c1aecc346066aa6a3fbfdc54237..794738f165b149212a6b25fd7b8739cc1ae27179 100755 (executable)
@@ -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