From: Tim Starling Date: Mon, 21 Oct 2013 04:18:04 +0000 (+1100) Subject: Fixes for duplicateStderr (I833aeb3a) X-Git-Tag: 1.31.0-rc.0~18349^2~1 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=b071c709d8798b1653d31288a977cc62b7f38e67;p=lhc%2Fweb%2Fwiklou.git Fixes for duplicateStderr (I833aeb3a) * Separate code from data. $2 in limit.sh is an option list. * Don't duplicate stderr on linux when limit.sh is not used, unless duplicateStderr is specified Change-Id: I8e6e74810864830c12af627bfbe75e74ba34e3e3 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 8241d81ae9..d8e6b367b9 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2773,10 +2773,6 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array $cmd = $envcmd . $cmd; if ( php_uname( 's' ) == 'Linux' ) { - $stderrDuplication = ''; - if ( $includeStderr ) { - $stderrDuplication = 'exec 2>&1; '; - } $time = intval ( isset( $limits['time'] ) ? $limits['time'] : $wgMaxShellTime ); if ( isset( $limits['walltime'] ) ) { $wallTime = intval( $limits['walltime'] ); @@ -2792,14 +2788,14 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array $cmd = '/bin/bash ' . escapeshellarg( "$IP/includes/limit.sh" ) . ' ' . escapeshellarg( $cmd ) . ' ' . escapeshellarg( - $stderrDuplication . + "MW_INCLUDE_STDERR=" . ( $includeStderr ? '1' : '' ) . ';' . "MW_CPU_LIMIT=$time; " . 'MW_CGROUP=' . escapeshellarg( $wgShellCgroup ) . '; ' . "MW_MEM_LIMIT=$mem; " . "MW_FILE_SIZE_LIMIT=$filesize; " . "MW_WALL_CLOCK_LIMIT=$wallTime" ); - } else { + } elseif ( $includeStderr ) { $cmd .= ' 2>&1'; } } elseif ( $includeStderr ) { diff --git a/includes/limit.sh b/includes/limit.sh index 6c4690ecd7..2a1545b64e 100644 --- a/includes/limit.sh +++ b/includes/limit.sh @@ -6,6 +6,7 @@ # and is available on most Linux systems. If Perl was distributed with # BSD::Resource included, we would happily use that instead, but it isn't. +MW_INCLUDE_STDERR= MW_CPU_LIMIT=0 MW_CGROUP= MW_MEM_LIMIT=0 @@ -15,6 +16,10 @@ MW_WALL_CLOCK_LIMIT=0 # Override settings eval "$2" +if [ -n "$MW_INCLUDE_STDERR" ]; then + exec 2>&1 +fi + if [ "$MW_CPU_LIMIT" -gt 0 ]; then ulimit -t "$MW_CPU_LIMIT" fi