/[gentoo-x86]/eclass/multiprocessing.eclass
Gentoo

Diff of /eclass/multiprocessing.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.7 Revision 1.8
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/multiprocessing.eclass,v 1.7 2013/12/07 09:14:15 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multiprocessing.eclass,v 1.8 2013/12/21 09:40:37 vapier Exp $
4 4
5# @ECLASS: multiprocessing.eclass 5# @ECLASS: multiprocessing.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @AUTHOR: 8# @AUTHOR:
33# multijob_finish 33# multijob_finish
34# @CODE 34# @CODE
35 35
36if [[ ${___ECLASS_ONCE_MULTIPROCESSING} != "recur -_+^+_- spank" ]] ; then 36if [[ ${___ECLASS_ONCE_MULTIPROCESSING} != "recur -_+^+_- spank" ]] ; then
37___ECLASS_ONCE_MULTIPROCESSING="recur -_+^+_- spank" 37___ECLASS_ONCE_MULTIPROCESSING="recur -_+^+_- spank"
38
39# @FUNCTION: bashpid
40# @DESCRIPTION:
41# Return the process id of the current sub shell. This is to support bash
42# versions older than 4.0 that lack $BASHPID support natively. Simply do:
43# echo ${BASHPID:-$(bashpid)}
44#
45# Note: Using this func in any other way than the one above is not supported.
46bashpid() {
47 # Running bashpid plainly will return incorrect results. This func must
48 # be run in a subshell of the current subshell to get the right pid.
49 # i.e. This will show the wrong value:
50 # bashpid
51 # But this will show the right value:
52 # (bashpid)
53 sh -c 'echo ${PPID}'
54}
38 55
39# @FUNCTION: makeopts_jobs 56# @FUNCTION: makeopts_jobs
40# @USAGE: [${MAKEOPTS}] 57# @USAGE: [${MAKEOPTS}]
41# @DESCRIPTION: 58# @DESCRIPTION:
42# Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number 59# Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number
140 --pre) mode="pre" ; shift ;; 157 --pre) mode="pre" ; shift ;;
141 --post) mode="post"; shift ;; 158 --post) mode="post"; shift ;;
142 esac 159 esac
143 160
144 if [[ $# -eq 0 ]] ; then 161 if [[ $# -eq 0 ]] ; then
145 trap 'echo ${BASHPID} $? >&'${mj_write_fd} EXIT 162 trap 'echo ${BASHPID:-$(bashpid)} $? >&'${mj_write_fd} EXIT
146 trap 'exit 1' INT TERM 163 trap 'exit 1' INT TERM
147 else 164 else
148 local ret 165 local ret
149 [[ ${mode} == "pre" ]] && { multijob_pre_fork; ret=$?; } 166 [[ ${mode} == "pre" ]] && { multijob_pre_fork; ret=$?; }
150 ( multijob_child_init ; "$@" ) & 167 ( multijob_child_init ; "$@" ) &

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.20