Skip to content

[Console] OS X Can't call cli_set_process_title php without superuser #21076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2016
Merged

[Console] OS X Can't call cli_set_process_title php without superuser #21076

merged 1 commit into from
Dec 30, 2016

Conversation

ogizanagi
Copy link
Contributor

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

The console component test suite is failing on OS X (10.12.2) as the cli_set_process_title function seems not to be allowed to be called without superuser. It seems to be an OS X limitation.
At least, the test suite should pass and a warning should be shown when using the component with this feature on OS X.


refs:

@@ -227,7 +227,15 @@ public function run(InputInterface $input, OutputInterface $output)

if (null !== $this->processTitle) {
if (function_exists('cli_set_process_title')) {
cli_set_process_title($this->processTitle);
$success = @cli_set_process_title($this->processTitle);
if (!$success) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if (@cli_set_process_title($this->processTitle)) { instead?

$success = @cli_set_process_title($this->processTitle);
if (!$success) {
if ('Darwin' === PHP_OS) {
$output->writeln('<comment>Running "cli_get_process_title" not as a superuser is not supported on OS X.</comment>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running "cli_get_process_title()" as an unprivileged user [...]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. It's way better :)

$output->writeln('<comment>Running "cli_get_process_title" not as a superuser is not supported on OS X.</comment>');
} else {
$error = error_get_last();
trigger_error($error['message'], E_USER_WARNING);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of E_USER_WARNING this should be $error['type'], shouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. But php forbids to use a E_* error type. Only E_USER_* are allowed.
Here I know it'll always be a E_WARNING as documented in the manual. So I just need to use E_USER_WARNING

@@ -328,6 +328,11 @@ 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()) {
if ('Darwin' === PHP_OS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (null === @cli_get_process_title() && 'Darwin' === PHP_OS)

@xabbuh
Copy link
Member

xabbuh commented Dec 28, 2016

👍

Status: Reviewed

cli_set_process_title($this->processTitle);
if (false === @cli_set_process_title($this->processTitle)) {
if ('Darwin' === PHP_OS) {
$output->writeln('<comment>Running "cli_get_process_title" as an unprivileged user is not supported on OS X.</comment>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS X -> MacOS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@fabpot
Copy link
Member

fabpot commented Dec 30, 2016

Thank you @ogizanagi.

@fabpot fabpot merged commit 9928c0d into symfony:2.7 Dec 30, 2016
fabpot added a commit that referenced this pull request Dec 30, 2016
…t superuser (ogizanagi)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] OS X Can't call cli_set_process_title php without superuser

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

The console component test suite is failing on OS X (10.12.2) as the `cli_set_process_title` function seems not to be allowed to be called without superuser. It seems to be an OS X limitation.
At least, the test suite should pass and a warning should be shown when using the component with this feature on OS X.

---

refs:

- http://stackoverflow.com/questions/27803120/cannot-set-process-title-in-a-php-command-line-script-using-cli-set-process-titl
- liip/php-osx#139
- zfcampus/zf-console#22

Commits
-------

9928c0d [Console] OS X Can't call cli_set_process_title php without superuser
@ogizanagi ogizanagi deleted the fix/2.7/console/process_title_osx branch December 30, 2016 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants