$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'] );
$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 ) {
# 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
# 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