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

Commit ea89256

Browse filesBrowse files
bug #58332 [Console] Suppress proc_open errors within Terminal::readFromProcess (fritzmg)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] Suppress `proc_open` errors within `Terminal::readFromProcess` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT When instantiating `SymfonyStyle` in a command it will try to determine the maximum width of the current console interface. https://github.com/symfony/symfony/blob/6687e4ea35f45ebd73fb0315938103628cfb13a0/src/Symfony/Component/Console/Style/SymfonyStyle.php#L53 This will execute `stty -a | grep columns` down the line. Access to `stty` 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 of `Terminal::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, since `Terminal::readFromProcess` already checks for ```php if (!$process = proc_open(…)) { return null; } ``` and ```php if (!\is_resource($process)) { return null; } ``` upstream in Symfony 6/7, indicating that `proc_open` might fail - this error can additionally be suppressed using `@`. Besides, `Process::start` also uses ``@proc_open`` (added in symfony/symfony@099481f "Prevent warning in proc_open()"). Commits ------- 575249a3431 suppress proc_open errors
2 parents 0deed11 + 97f0e2d commit ea89256
Copy full SHA for ea89256

File tree

Expand file treeCollapse file tree

1 file changed

+1
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-1
lines changed

‎Terminal.php

Copy file name to clipboardExpand all lines: Terminal.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private static function readFromProcess(string $command): ?string
158158

159159
$cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0;
160160

161-
if (!$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true])) {
161+
if (!$process = @proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true])) {
162162
return null;
163163
}
164164

0 commit comments

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