From 9928c0d44e21201ec86f23b1316e797f1d303f90 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 28 Dec 2016 14:01:35 +0100 Subject: [PATCH] [Console] OS X Can't call cli_set_process_title php without superuser --- src/Symfony/Component/Console/Command/Command.php | 9 ++++++++- .../Component/Console/Tests/Command/CommandTest.php | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 9bcfdf79cacec..ff4075962e45a 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -227,7 +227,14 @@ public function run(InputInterface $input, OutputInterface $output) if (null !== $this->processTitle) { if (function_exists('cli_set_process_title')) { - cli_set_process_title($this->processTitle); + if (false === @cli_set_process_title($this->processTitle)) { + if ('Darwin' === PHP_OS) { + $output->writeln('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); + } else { + $error = error_get_last(); + trigger_error($error['message'], E_USER_WARNING); + } + } } elseif (function_exists('setproctitle')) { setproctitle($this->processTitle); } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 2c63387116849..1468cbe2ea58a 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -328,6 +328,9 @@ public function testRunWithProcessTitle() $command->setProcessTitle('foo'); $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); if (function_exists('cli_set_process_title')) { + if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) { + $this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); + } $this->assertEquals('foo', cli_get_process_title()); } }