add a __bashpid helper for <bash-4.0 versions
[portage.git] / bin / isolated-functions.sh
index 42d9e708d52c97432901a43d5c5caa7529287f39..b99aec729555e249d37d0d47a2fae9fb6f461036 100644 (file)
@@ -98,6 +98,13 @@ nonfatal() {
        PORTAGE_NONFATAL=1 "$@"
 }
 
+__bashpid() {
+       # The BASHPID variable is new to bash-4.0, so add a hack for older
+       # versions.  This must be used like so:
+       # ${BASHPID:-$(__bashpid)}
+       sh -c 'echo ${PPID}'
+}
+
 __helpers_die() {
        if ___eapi_helpers_can_die; then
                die "$@"
@@ -216,7 +223,7 @@ die() {
        [[ -n $PORTAGE_IPC_DAEMON ]] && "$PORTAGE_BIN_PATH"/ebuild-ipc exit 1
 
        # subshell die support
-       [[ $BASHPID = $EBUILD_MASTER_PID ]] || kill -s SIGTERM $EBUILD_MASTER_PID
+       [[ ${BASHPID:-$(__bashpid)} == ${EBUILD_MASTER_PID} ]] || kill -s SIGTERM ${EBUILD_MASTER_PID}
        exit 1
 }