Experimental ulimit script
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 26 Nov 2005 00:06:42 +0000 (00:06 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 26 Nov 2005 00:06:42 +0000 (00:06 +0000)
.cvsignore
bin/ulimit.sh [new file with mode: 0644]
includes/GlobalFunctions.php

index 44ddd60..f436e3a 100644 (file)
@@ -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 (file)
index 0000000..7a1925c
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+ulimit -t $1
+ulimit -v $2
+shift 2
+"$@"
+
index d459466..3d0ac19 100644 (file)
@@ -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 );
+}
+
 ?>