Skip to content

Commit

Permalink
[Process] Fix #9861 : Revert TTY mode
Browse files Browse the repository at this point in the history
  • Loading branch information
romainneutron committed Jan 7, 2014
1 parent b2d594d commit 160b1cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/Symfony/Component/Process/Process.php
Expand Up @@ -246,6 +246,13 @@ public function start($callback = null)
$this->status = self::STATUS_STARTED;

$this->processPipes->unblock();

if ($this->tty) {
$this->status = self::STATUS_TERMINATED;

return;
}

$this->processPipes->write(false, $this->stdin);
$this->updateStatus(false);
$this->checkTimeout();
Expand Down Expand Up @@ -740,7 +747,7 @@ public function setTty($tty)
}

/**
* Checks if the TTY mode is enabled.
* Checks if the TTY mode is enabled.
*
* @return Boolean true if the TTY mode is enabled, false otherwise
*/
Expand Down Expand Up @@ -941,7 +948,7 @@ public function checkTimeout()
*/
private function getDescriptors()
{
$this->processPipes = new ProcessPipes($this->useFileHandles);
$this->processPipes = new ProcessPipes($this->useFileHandles, $this->tty);
$descriptors = $this->processPipes->getDescriptors();

if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
Expand Down
13 changes: 12 additions & 1 deletion src/Symfony/Component/Process/ProcessPipes.php
Expand Up @@ -26,10 +26,13 @@ class ProcessPipes
private $readBytes = array();
/** @var Boolean */
private $useFiles;
/** @var Boolean */
private $ttyMode;

public function __construct($useFiles = false)
public function __construct($useFiles, $ttyMode)
{
$this->useFiles = (Boolean) $useFiles;
$this->ttyMode = (Boolean) $ttyMode;

// 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.
Expand Down Expand Up @@ -108,6 +111,14 @@ public function getDescriptors()
);
}

if ($this->ttyMode) {
return array(
array('file', '/dev/tty', 'r'),
array('file', '/dev/tty', 'w'),
array('file', '/dev/tty', 'w'),
);
}

return array(
array('pipe', 'r'), // stdin
array('pipe', 'w'), // stdout
Expand Down

0 comments on commit 160b1cf

Please sign in to comment.