diff options
author | Mike Frysinger <vapier@gentoo.org> | 2013-12-21 09:40:37 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2013-12-21 09:40:37 +0000 |
commit | 4b210fbfcd5c8cd5ed76b99c132570ecf6f56133 (patch) | |
tree | ae649f6360564c3c1deff5e57d8eb6e0e598e1e0 | |
parent | Version bump. (diff) | |
download | gentoo-2-4b210fbfcd5c8cd5ed76b99c132570ecf6f56133.tar.gz gentoo-2-4b210fbfcd5c8cd5ed76b99c132570ecf6f56133.tar.bz2 gentoo-2-4b210fbfcd5c8cd5ed76b99c132570ecf6f56133.zip |
add support for bash-3.2 which lacks $BASHPID as pointed out by Ryan Hill
-rw-r--r-- | eclass/multiprocessing.eclass | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass index 0b3c59999d38..0ee0abaafd05 100644 --- a/eclass/multiprocessing.eclass +++ b/eclass/multiprocessing.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/multiprocessing.eclass,v 1.7 2013/12/07 09:14:15 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/multiprocessing.eclass,v 1.8 2013/12/21 09:40:37 vapier Exp $ # @ECLASS: multiprocessing.eclass # @MAINTAINER: @@ -36,6 +36,23 @@ if [[ ${___ECLASS_ONCE_MULTIPROCESSING} != "recur -_+^+_- spank" ]] ; then ___ECLASS_ONCE_MULTIPROCESSING="recur -_+^+_- spank" +# @FUNCTION: bashpid +# @DESCRIPTION: +# Return the process id of the current sub shell. This is to support bash +# versions older than 4.0 that lack $BASHPID support natively. Simply do: +# echo ${BASHPID:-$(bashpid)} +# +# Note: Using this func in any other way than the one above is not supported. +bashpid() { + # Running bashpid plainly will return incorrect results. This func must + # be run in a subshell of the current subshell to get the right pid. + # i.e. This will show the wrong value: + # bashpid + # But this will show the right value: + # (bashpid) + sh -c 'echo ${PPID}' +} + # @FUNCTION: makeopts_jobs # @USAGE: [${MAKEOPTS}] # @DESCRIPTION: @@ -142,7 +159,7 @@ multijob_child_init() { esac if [[ $# -eq 0 ]] ; then - trap 'echo ${BASHPID} $? >&'${mj_write_fd} EXIT + trap 'echo ${BASHPID:-$(bashpid)} $? >&'${mj_write_fd} EXIT trap 'exit 1' INT TERM else local ret |