bug #11121 [2.5][Process] Do not redirect output to file handles when output is disabled, simply discard it (romainneutron)
This PR was merged into the 2.5 branch.
Discussion
----------
[2.5][Process] Do not redirect output to file handles when output is disabled, simply discard it
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
Commits
-------
b35250f
[Process] Do not redirect output to file handles when output is disabled
This commit is contained in:
commit
fd1bfd4e85
@ -1238,8 +1238,8 @@ class Process
|
||||
*/
|
||||
private function getDescriptors()
|
||||
{
|
||||
$this->processPipes = new ProcessPipes($this->useFileHandles, $this->tty, $this->pty);
|
||||
$descriptors = $this->processPipes->getDescriptors($this->outputDisabled);
|
||||
$this->processPipes = new ProcessPipes($this->useFileHandles, $this->tty, $this->pty, $this->outputDisabled);
|
||||
$descriptors = $this->processPipes->getDescriptors();
|
||||
|
||||
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
|
||||
|
@ -32,20 +32,23 @@ class ProcessPipes
|
||||
private $ttyMode;
|
||||
/** @var bool */
|
||||
private $ptyMode;
|
||||
/** @var bool */
|
||||
private $disableOutput;
|
||||
|
||||
const CHUNK_SIZE = 16384;
|
||||
|
||||
public function __construct($useFiles, $ttyMode, $ptyMode = false)
|
||||
public function __construct($useFiles, $ttyMode, $ptyMode = false, $disableOutput = false)
|
||||
{
|
||||
$this->useFiles = (bool) $useFiles;
|
||||
$this->ttyMode = (bool) $ttyMode;
|
||||
$this->ptyMode = (bool) $ptyMode;
|
||||
$this->disableOutput = (bool) $disableOutput;
|
||||
|
||||
// Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big.
|
||||
// Workaround for this problem is to use temporary files instead of pipes on Windows platform.
|
||||
//
|
||||
// @see https://bugs.php.net/bug.php?id=51800
|
||||
if ($this->useFiles) {
|
||||
if ($this->useFiles && !$this->disableOutput) {
|
||||
$this->files = array(
|
||||
Process::STDOUT => tempnam(sys_get_temp_dir(), 'sf_proc_stdout'),
|
||||
Process::STDERR => tempnam(sys_get_temp_dir(), 'sf_proc_stderr'),
|
||||
@ -107,13 +110,11 @@ class ProcessPipes
|
||||
/**
|
||||
* Returns an array of descriptors for the use of proc_open.
|
||||
*
|
||||
* @param bool $disableOutput Whether to redirect STDOUT and STDERR to /dev/null or not.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDescriptors($disableOutput)
|
||||
public function getDescriptors()
|
||||
{
|
||||
if ($disableOutput) {
|
||||
if ($this->disableOutput) {
|
||||
$nullstream = fopen(defined('PHP_WINDOWS_VERSION_BUILD') ? 'NUL' : '/dev/null', 'c');
|
||||
|
||||
return array(
|
||||
|
Reference in New Issue
Block a user