From: Tim Starling Date: Sat, 26 Nov 2005 00:06:42 +0000 (+0000) Subject: Experimental ulimit script X-Git-Tag: 1.6.0~1133 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=deefc32fea5215abaf4011c8e3671555f87a6216;p=lhc%2Fweb%2Fwiklou.git Experimental ulimit script --- diff --git a/.cvsignore b/.cvsignore index 44ddd60766..f436e3ab79 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,7 +1,6 @@ LocalSettings.php AdminSettings.php *~ -bin .classpath .project project.index diff --git a/bin/ulimit.sh b/bin/ulimit.sh new file mode 100644 index 0000000000..7a1925cc27 --- /dev/null +++ b/bin/ulimit.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +ulimit -t $1 +ulimit -v $2 +shift 2 +"$@" + diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d459466c1f..3d0ac194a8 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1572,4 +1572,19 @@ function wfIsWellFormedXmlFragment( $text ) { return wfIsWellFormedXml( $html ); } +/** + * shell_exec() with time and memory limits mirrored from the PHP configuration, + * if supported. + */ +function wfShellExec( $cmd ) +{ + global $IP; + if ( php_uname( 's' ) == 'Linux' ) { + $time = ini_get( 'max_execution_time' ); + $memKB = intval( ini_get( 'memory_limit' ) / 1024 ); + $cmd = escapeshellarg( "$IP/ulimit.sh" ) . " $time $memKB $cmd"; + } + return shell_exec( $cmd ); +} + ?>