Skip to content

[Console] Don't register signal handlers if pcntl is disabled #38589

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
Oct 16, 2020

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Oct 15, 2020

Q A
Branch? 5.x
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #38496
License MIT
Doc PR todo

This PR skips the default signal registration when pcntl is not installed or disabled via the disable_functions INI directive (which is common for prod infrastructures).
When registering a SignalableCommand, a clear exception is thrown.

Best reviewed without whitespaces

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

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

I like it 👍🏼

@chalasr chalasr force-pushed the disable_pcntl branch 3 times, most recently from 1fe2517 to 1c0e10c Compare October 15, 2020 23:24
@fabpot
Copy link
Member

fabpot commented Oct 16, 2020

Thank you @chalasr.

@fabpot fabpot merged commit dda1fe9 into symfony:5.x Oct 16, 2020
@chalasr chalasr deleted the disable_pcntl branch October 16, 2020 07:33
$this->signalRegistry = new SignalRegistry();
if (\defined('SIGINT')) {
if (\defined('SIGINT') && SignalRegistry::isSupported()) {
$this->signalRegistry = new SignalRegistry();
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the late review, but the PR has changed before my review.
So here we go:

This change is wrong. See getSignalRegistry() method:
https://github.com/chalasr/symfony/blob/8fe876341e860ea3fa13bec3c2bdf77a66ead424/src/Symfony/Component/Console/Application.php#L111-L114

Then, a lot of fatal error could occurs since the registry might not be defined

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, thank you; #38602 makes it nullable

lyrixx added a commit that referenced this pull request Oct 16, 2020
This PR was merged into the 5.x branch.

Discussion
----------

[Console] Fix signal management

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Missed in #38589

Commits
-------

36e41b8 [Console] Fix Application::getSignalRegistry() retval
@fabpot fabpot mentioned this pull request Oct 28, 2020
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.

[Console] "pcntl_signal_get_handler() has been disabled for security reasons" during installation
6 participants