Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Ensure terminal is usable after termination signal#61861

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.4fromjohnstevenson:sigbug
Oct 2, 2025

Conversation

@johnstevenson
Copy link
Contributor

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#61732
LicenseMIT

This PR introduces a new helperTerminalInputHelper that restores the terminal to its original state after it has been modified when reading using input. This ensures that the terminal is not broken when a terminating signal, like Ctrl-C, is received.

QuestionHelper.php disablesicanon andecho when accepting input from a selection, and disablesecho when accepting hidden input. If these are not restored before termination, the user's terminal can end up in a broken state.

Usage:

$inputHelper =newTerminalInputHelper($inputStream);// Change terminal settings then wait for input before all input reads$inputHelper->waitForInput();// Read the input then call finish to restore terminal settings and signal handlers$inputHelper->finish()

The helper creates its own signal handlers (forSIGINT,SIGQUIT, andSIGTERM) that restore the original terminal settings then call any original handler callback. If the original handler callback does not terminate the process then the current terminal settings are restored.

If there is no original signal handler callback and the signal's disposition is set to the default action (SIG_DFL), then that action is invoked by aposix_kill call.

Thefinish method restores the terminal settings and replaces the new signal handlers with the original ones.

@carsonbotcarsonbot added this to the6.4 milestoneSep 26, 2025
@carsonbotcarsonbot changed the titleEnsure terminal is usable after termination signal Ensure terminal is usable after termination signalSep 26, 2025
@chalasr
Copy link
Member

Do you have a use case for using this helper in your own commands whether coming from a Symfony application or a reusable bundle? Elsewhere than in core I mean.

@johnstevenson
Copy link
ContributorAuthor

Do you have a use case for using this helper in your own commands...

Not at all. The helper is to fix the issues with Symfony/Console.

@johnstevenson
Copy link
ContributorAuthor

I've just noticed this issue#61852 (that has been closed). This PR fixes the problem described, which is having to hit Enter after a Ctrl-C to send the signal (when submitting hidden input).

@chalasr
Copy link
Member

Please inline back the logic into Application and QuestionHelper. Helpers in this namespace are part of Console's public API, but I can't think of a use case for this helper in userland either and I looking at it, I don't think it's worth it. Expanding the public API is a feature also while this PR is a bugfix targeting a branch that is in maintenance mode, so please do the minimum changes to fix the bug at hand. Thanks

@stof
Copy link
Member

Given the need for extra state in this input helper, I'm fine with using a separate class. But it should be@internal

@chalasr
Copy link
Member

The non-obvious name of that helper annoys me but probably fine if it’s internal. Works for me

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Here's some nitpicking.

@johnstevenson
Copy link
ContributorAuthor

The non-obvious name of that helper annoys me ....

I tried several before choosing the least annoying. Feel free to suggest an alternative.

@valx76
Copy link

The non-obvious name of that helper annoys me ....

I tried several before choosing the least annoying. Feel free to suggest an alternative.

I can think ofInputSignalHelper orSignalSafeTerminalInputHelper.
Don't know if it's any better, what do you think?

@carsonbotcarsonbot changed the title Ensure terminal is usable after termination signal[Console] Ensure terminal is usable after termination signalOct 1, 2025
@fabpot
Copy link
Member

Thank you@johnstevenson.

@fabpotfabpot merged commit07a5ed4 intosymfony:6.4Oct 2, 2025
@johnstevensonjohnstevenson deleted the sigbug branchOctober 2, 2025 09:20
@fabpotfabpot mentioned this pull requestOct 28, 2025
@fabpotfabpot mentioned this pull requestOct 28, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

8 participants

@johnstevenson@chalasr@stof@valx76@fabpot@nicolas-grekas@OskarStark@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp