Skip to content

[Console] SIGINT not intercepted, process is stopped #48205

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

Closed
GromNaN opened this issue Nov 12, 2022 · 2 comments
Closed

[Console] SIGINT not intercepted, process is stopped #48205

GromNaN opened this issue Nov 12, 2022 · 2 comments

Comments

@GromNaN
Copy link
Member

GromNaN commented Nov 12, 2022

Symfony version(s) affected

since 6.1.4 - 6.1.x-dev - 6.2.x-dev

Description

Using SignalableCommandInterface to intercept the signal SIGINT, the process is stopped while it was still running on previous minor versions.

How to reproduce

For Symfony World Online 2022, I created a sample command (code) to play with signals.

https://asciinema.org/a/su5VlgGiuRTBqSD4OXqSNn0XP

The command bin/console app:signal display a progress bar that change direction when Ctrl+C is hit.

When symfony/console is updated to 6.1.4 or newer, Ctrl+C stops the process.
https://asciinema.org/a/537232

Possible Solution

Related merge requests:

Full diff: symfony/console@v6.1.3...v6.1.4

Additional Context

No response

@GromNaN
Copy link
Member Author

GromNaN commented Nov 13, 2022

Here is a hint: SignalRegistry $hasNext is true on 6.1.3 and false on 6.1.4.

@GromNaN
Copy link
Member Author

GromNaN commented Nov 13, 2022

The order in which the signal handlers are registered have been modified in https://github.com/symfony/symfony/pull/45333/files#diff-8f1fd83284712ab08cb5d391da70ea0e78719ef08db852596997a4085848a026R996-R998

before

  1. stty
  2. EventDispatcher::dispatch() and exit if last
  3. SignalableCommandInterface::getSubscribedSignals()

after

  1. stty
  2. SignalableCommandInterface::getSubscribedSignals()
  3. EventDispatcher::dispatch() and exit if last

nicolas-grekas added a commit that referenced this issue Nov 14, 2022
…s and skip exit (GromNaN)

This PR was merged into the 5.4 branch.

Discussion
----------

[Console]  Fix signal handlers called after event listeners and skip exit

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #48205
| License       | MIT
| Doc PR        | -

Restore registration of signal handlers after the event dispatcher.
https://github.com/symfony/symfony/pull/45333/files#diff-8f1fd83284712ab08cb5d391da70ea0e78719ef08db852596997a4085848a026L1009

Commits
-------

eebfd6e Fix signal handlers called after event listeners and skip exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants