8000 [Process] Do not redirect output to file handles when output is disabled · tommygnr/symfony@b35250f · GitHub
[go: up one dir, main page]

Skip to content

Commit b35250f

Browse files
committed
[Process] Do not redirect output to file handles when output is disabled
1 parent 88a954c commit b35250f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,8 @@ public static function isPtySupported()
12381238
*/
12391239
private function getDescriptors()
12401240
{
1241-
$this->processPipes = new ProcessPipes($this->useFileHandles, $this->tty, $this->pty);
1242-
$descriptors = $this->processPipes->getDescriptors($this->outputDisabled);
1241+
$this->processPipes = new ProcessPipes($this->useFileHandles, $this->tty, $this->pty, $this->outputDisabled);
1242+
$descriptors = $this->processPipes->getDescriptors();
12431243

12441244
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
12451245
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild

src/Symfony/Component/Process/ProcessPipes.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ class ProcessPipes
3232
private $ttyMode;
3333
/** @var bool */
3434
private $ptyMode;
35+
/** @var bool */
36+
private $disableOutput;
3537

3638
const CHUNK_SIZE = 16384;
3739

38-
public function __construct($useFiles, $ttyMode, $ptyMode = false)
40+
public function __construct($useFiles, $ttyMode, $ptyMode = false, $disableOutput = false)
3941
{
4042
$this->useFiles = (bool) $useFiles;
4143
$this->ttyMode = (bool) $ttyMode;
4244
$this->ptyMode = (bool) $ptyMode;
45+
$this->disableOutput = (bool) $disableOutput;
4346

4447
// Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big.
4548
// Workaround for this problem is to use temporary files instead of pipes on Windows platform.
4649
//
4750
// @see https://bugs.php.net/bug.php?id=51800
48-
if ($this->useFiles) {
51+
if ($this->useFiles && !$this->disableOutput) {
4952
$this->files = array(
5053
Process::STDOUT => tempnam(sys_get_temp_dir(), 'sf_proc_stdout'),
5154
Process::STDERR => tempnam(sys_get_temp_dir(), 'sf_proc_stderr'),
@@ -107,13 +110,11 @@ public function closeUnixPipes()
107110
/**
108111
* Returns an array of descriptors for the use of proc_open.
109112
*
110-
* @param bool $disableOutput Whether to redirect STDOUT and STDERR to /dev/null or not.
111-
*
112113
* @return array
113114
*/
114-
public function getDescriptors($disableOutput)
115+
public function getDescriptors()
115116
{
116-
if ($disableOutput) {
117+
if ($this->disableOutput) {
117118
$nullstream = fopen(defined('PHP_WINDOWS_VERSION_BUILD') ? 'NUL' : '/dev/null', 'c');
118119

119120
return array(

0 commit comments

Comments
 (0)
0