diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 44b8a9393b7b..9754661fb5ff 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -68,6 +68,7 @@ class Application private $dispatcher; private $terminalDimensions; private $defaultCommand; + private $processTitle = '%app% - %cmd%'; /** * Constructor. @@ -883,6 +884,15 @@ protected function configureIO(InputInterface $input, OutputInterface $output) */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { + if (version_compare(PHP_VERSION, '5.5.0') >= 0) { + $processTitle = strtr($this->processTitle, array( + '%app%' => $this->name, + '%cmd%' => $command->getName(), + )); + + @cli_set_process_title($processTitle); + } + foreach ($command->getHelperSet() as $helper) { if ($helper instanceof InputAwareInterface) { $helper->setInput($input); @@ -1109,4 +1119,18 @@ public function setDefaultCommand($commandName) { $this->defaultCommand = $commandName; } + + /** + * Sets the process title visible in tools such as top and ps. + * The available placeholders are: + * + * - %app% This application name + * - %cmd% The running command name + * + * @param string $processTitle The process title + */ + public function setProcessTitle($processTitle) + { + $this->processTitle = $processTitle; + } }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: