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

Appearance settings

Conversation

valx76
Copy link

@valx76 valx76 commented Oct 5, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues
License MIT

QuestionHelper is blocking signals because of its fgets/fgetc use.
This PR uses fread so signals can be dispatched in text inputs.
Since Windows is not supported by the PCNTL extension, it was working fine on this OS.
This change has been tested in Windows, Linux and MacOS.

Note

This PR replaces #61878.


Snippet to test the behavior manually:

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

#[AsCommand('app:test')]
class TestCommand extends Command
{
    protected function configure(): void
    {
        $this->addArgument('mode', InputArgument::OPTIONAL, default: 'single');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $mode = $input->getArgument('mode');

        $question = new Question('Enter text: ');
        $question->setMultiline($mode !== 'single');

        $helper = new QuestionHelper();
        $result = $helper->ask($input, $output, $question);

        $output->writeln('Result: '.$result);

        return Command::SUCCESS;
    }
}

Usage:

  • Single line input: php bin/console app:test single
  • Multiline input: php bin/console app:test multi

@valx76 valx76 requested a review from chalasr as a code owner October 5, 2025 18:22
@carsonbot carsonbot added this to the 6.4 milestone Oct 5, 2025
@carsonbot carsonbot changed the title Handle signals on text input Handle signals on text input Oct 5, 2025
@valx76 valx76 changed the title Handle signals on text input [Console] Handle signals on text input Oct 5, 2025
@valx76 valx76 requested a review from nicolas-grekas October 8, 2025 20:33
@valx76
Copy link
Author

valx76 commented Oct 8, 2025

@nicolas-grekas I've updated the code based on your comments :).
Just FYI - I didn't test the changes in Windows yet

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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.