🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@valx76
Copy link
Contributor

@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
Contributor 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

@nicolas-grekas nicolas-grekas force-pushed the bugfix/handle-signals-on-text-input branch from 37a68f9 to 7c40cad Compare December 5, 2025 13:47
@nicolas-grekas
Copy link
Member

Thank you @valx76.

@nicolas-grekas nicolas-grekas merged commit e041cb3 into symfony:6.4 Dec 5, 2025
7 of 11 checks passed
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