From 204a25e3d550d446146906f9f3c31d9bb0798e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Sun, 15 Dec 2013 02:02:43 +0100 Subject: [PATCH] [Console] Added a way to set the process title --- src/Symfony/Component/Console/CHANGELOG.md | 5 ++++ .../Component/Console/Command/Command.php | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index 4d00cbb4285fa..313699836d2c7 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.5.0 +----- + +* added a way to set the process name of a command + 2.4.0 ----- diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 614a034c8c231..679a1c01b99db 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -33,6 +33,7 @@ class Command { private $application; private $name; + private $processName; private $aliases = array(); private $definition; private $help; @@ -212,6 +213,16 @@ protected function initialize(InputInterface $input, OutputInterface $output) */ public function run(InputInterface $input, OutputInterface $output) { + if (null !== $this->processName) { + if (function_exists('cli_set_process_title')) { + cli_set_process_title($this->processName); + } elseif (function_exists('setproctitle')) { + setproctitle($this->processName); + } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { + $output->writeln('Install the proctitle PECL to be able to change the process title.'); + } + } + // force the creation of the synopsis before the merge with the app definition $this->getSynopsis(); @@ -411,6 +422,25 @@ public function setName($name) return $this; } + /** + * Sets the process name of the command. + * + * This feature should be used only when creating a long process command, + * like a daemon. + * + * PHP 5.5+ or the proctitle PECL library is required + * + * @param string $name The process name + * + * @return Command The current instance + */ + public function setProcessName($name) + { + $this->processName = $name; + + return $this; + } + /** * Returns the command name. * pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy