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] Suppressproc_open errors withinTerminal::readFromProcess#58332

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

Conversation

fritzmg
Copy link
Contributor

@fritzmgfritzmg commentedSep 20, 2024
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Issues
LicenseMIT

When instantiatingSymfonyStyle in a command it will try to determine the maximum width of the current console interface.

$width = (newTerminal())->getWidth() ?:self::MAX_LINE_LENGTH;

This will executestty -a | grep columns down the line. Access tostty might be disallowed however, resulting in the following error:

ErrorException: Warning: proc_open(): Exec failed: Permission denied#16 /vendor/symfony/console/Terminal.php(220): Symfony\Component\Console\Terminal::readFromProcess#15 /vendor/symfony/console/Terminal.php(204): Symfony\Component\Console\Terminal::getSttyColumns#14 /vendor/symfony/console/Terminal.php(170): Symfony\Component\Console\Terminal::initDimensionsUsingStty#13 /vendor/symfony/console/Terminal.php(153): Symfony\Component\Console\Terminal::initDimensions#12 /vendor/symfony/console/Terminal.php(94): Symfony\Component\Console\Terminal::getWidth#11 /vendor/symfony/console/Style/SymfonyStyle.php(55): Symfony\Component\Console\Style\SymfonyStyle::__construct#10 /vendor/symfony/messenger/Command/ConsumeMessagesCommand.php(136): Symfony\Component\Messenger\Command\ConsumeMessagesCommand::interact#9 /vendor/symfony/console/Command/Command.php(311): Symfony\Component\Console\Command\Command::run

(Stack Trace actually from Symfony 6)

The phpDoc ofTerminal::getSttyColumns states

Runs and parses stty -a if it's available,suppressing any error output.

The latter might refer to['suppress_errors' => true] (though I am not sure) - which is a Windows only functionality. In any case, sinceTerminal::readFromProcess already checks for

if (!$process =proc_open(…)) {returnnull;}

and

if (!\is_resource($process)) {returnnull;}

upstream in Symfony 6/7, indicating thatproc_open might fail - this error can additionally be suppressed using@. Besides,Process::start also uses@proc_open (added in099481f "Prevent warning in proc_open()").

ameotoko reacted with thumbs up emoji
@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "7.2" but it seems your PR description refers to branch "5.4".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@fritzmgfritzmg changed the base branch from7.2 to5.4September 20, 2024 10:50
@fritzmg
Copy link
ContributorAuthor

Instead of usingproc_open directly, we could also useProcess, which would likely solve the issue. wdyt?

@nicolas-grekas
Copy link
Member

Thank you@fritzmg.

@nicolas-grekasnicolas-grekas merged commit2be812d intosymfony:5.4Sep 28, 2024
8 of 10 checks passed
@fritzmg
Copy link
ContributorAuthor

fritzmg commentedSep 28, 2024
edited
Loading

@nicolas-grekas should I do a separate PR for Symfony 6, as the code is different there?

@fritzmgfritzmg deleted the suppress-read-from-process-errors branchSeptember 28, 2024 11:22
@xabbuh
Copy link
Member

@fritzmg I think merging5.4 up solved this. But please send a PR if you think that something's still missing.

@fritzmg
Copy link
ContributorAuthor

Ah yes, all good 👍

xabbuh reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@xabbuhxabbuhxabbuh approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
5.4
Development

Successfully merging this pull request may close these issues.

4 participants
@fritzmg@carsonbot@nicolas-grekas@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp