8000 bug #45053 [Console] use STDOUT/ERR in ConsoleOutput to save opening … · symfony/symfony@3838696 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 /div>

Commit 3838696

Browse files
committed
bug #45053 [Console] use STDOUT/ERR in ConsoleOutput to save opening too many file descriptors (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Console] use STDOUT/ERR in ConsoleOutput to save opening too many file descriptors | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #44882 | License | MIT | Doc PR | - /cc @jtojnar can you please give this patch a try and report back? Commits ------- 6eaf9e6 [Console] use STDOUT/ERR in ConsoleOutput to save opening too many file descriptors
2 parents d560800 + 6eaf9e6 commit 3838696

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/Console/Output/ConsoleOutput.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,20 @@ private function openOutputStream()
153153
return fopen('php://output', 'w');
154154
}
155155

156-
return @fopen('php://stdout', 'w') ?: fopen('php://output', 'w');
156+
// Use STDOUT when possible to prevent from opening too many file descriptors
157+
return \defined('STDOUT') ? \STDOUT : (@fopen('php://stdout', 'w') ?: fopen('php://output', 'w'));
157158
}
158159

159160
/**
160161
* @return resource
161162
*/
162163
private function openErrorStream()
163164
{
164-
return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w');
165+
if (!$this->hasStderrSupport()) {
166+
return fopen('php://output', 'w');
167+
}
168+
169+
// Use STDERR when possible to prevent from opening too many file descriptors
170+
return \defined('STDERR') ? \STDERR : (@fopen('php://stderr', 'w') ?: fopen('php://output', 'w'));
165171
}
166172
}

0 commit comments

Comments
 (0)
0