From 864083ffd28eb4b60ee0f6ceb658866bcca0fa78 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 17 Jun 2006 10:21:55 +0000 Subject: [PATCH] Stop using memory_limit as a virtual memory limit for shell processes. Use a separate setting instead. --- includes/DefaultSettings.php | 5 +++++ includes/GlobalFunctions.php | 11 ++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d9af202a75..d1169a80a2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2098,4 +2098,9 @@ $wgAllowTitlesInSVG = false; */ $wgContentNamespaces = array( NS_MAIN ); +/** + * Maximum amount of virtual memory available to shell processes under linux, in KB. + */ +$wgMaxShellMemory = 102400; + ?> diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f6919991ca..e8f721f156 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1661,7 +1661,7 @@ function wfUrlProtocols() { * @return collected stdout as a string (trailing newlines stripped) */ function wfShellExec( $cmd, &$retval=null ) { - global $IP; + global $IP, $wgMaxShellMemory; if( ini_get( 'safe_mode' ) ) { wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" ); @@ -1671,15 +1671,12 @@ function wfShellExec( $cmd, &$retval=null ) { if ( php_uname( 's' ) == 'Linux' ) { $time = ini_get( 'max_execution_time' ); - $mem = ini_get( 'memory_limit' ); - if( preg_match( '/^([0-9]+)[Mm]$/', trim( $mem ), $m ) ) { - $mem = intval( $m[1] * (1024*1024) ); - } + $mem = intval( $wgMaxShellMemory ); + if ( $time > 0 && $mem > 0 ) { $script = "$IP/bin/ulimit.sh"; if ( is_executable( $script ) ) { - $memKB = intval( $mem / 1024 ); - $cmd = escapeshellarg( $script ) . " $time $memKB $cmd"; + $cmd = escapeshellarg( $script ) . " $time $mem $cmd"; } } } elseif ( php_uname( 's' ) == 'Windows NT' ) { -- 2.20.1