aboutsummaryrefslogtreecommitdiffstats
path: root/includes/shell/Shell.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/shell/Shell.php')
-rw-r--r--includes/shell/Shell.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/includes/shell/Shell.php b/includes/shell/Shell.php
index c293ff2110eb..f2c96aeb994f 100644
--- a/includes/shell/Shell.php
+++ b/includes/shell/Shell.php
@@ -22,6 +22,9 @@
namespace MediaWiki\Shell;
+use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
+
/**
* Executes shell commands
*
@@ -39,10 +42,10 @@ namespace MediaWiki\Shell;
class Shell {
/**
- * Returns a new instance of this class
+ * Returns a new instance of Command class
*
- * @param string|string[] $command If string, a properly shell-escaped command line,
- * or an array of unescaped arguments, in which case each value will be escaped
+ * @param string|string[] $command String or array of strings representing the command to
+ * be executed, each value will be escaped.
* Example: [ 'convert', '-font', 'font name' ] would produce "'convert' '-font' 'font name'"
* @return Command
*/
@@ -54,6 +57,18 @@ class Shell {
$args = reset( $args );
}
$command = new Command();
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+
+ $limits = [
+ 'time' => $config->get( 'MaxShellTime' ),
+ 'walltime' => $config->get( 'MaxShellWallClockTime' ),
+ 'memory' => $config->get( 'MaxShellMemory' ),
+ 'filesize' => $config->get( 'MaxShellFileSize' ),
+ ];
+ $command->limits( $limits );
+ $command->cgroup( $config->get( 'ShellCgroup' ) );
+ $command->setLogger( LoggerFactory::getInstance( 'exec' ) );
+
return $command->params( $args );
}