Skip to content

Commit

Permalink
[Process] Use stream based storage to avoid memory issues
Browse files Browse the repository at this point in the history
  • Loading branch information
romainneutron committed Jan 20, 2016
1 parent 6ec5537 commit 2d931f4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Symfony/Component/Process/Process.php
Expand Up @@ -491,6 +491,10 @@ public function getOutput()
*/
public function getIncrementalOutput()
{
if ($this->outputDisabled) {
throw new LogicException('Output has been disabled.');
}

$this->requireProcessIsStarted(__FUNCTION__);

$latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
Expand All @@ -510,7 +514,8 @@ public function getIncrementalOutput()
*/
public function clearOutput()
{
$this->stdout = '';
ftruncate($this->stdout, 0);
fseek($this->stdout, 0);
$this->incrementalOutputOffset = 0;

return $this;
Expand Down Expand Up @@ -555,6 +560,10 @@ public function getErrorOutput()
*/
public function getIncrementalErrorOutput()
{
if ($this->outputDisabled) {
throw new LogicException('Output has been disabled.');
}

$this->requireProcessIsStarted(__FUNCTION__);

$latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
Expand All @@ -574,7 +583,8 @@ public function getIncrementalErrorOutput()
*/
public function clearErrorOutput()
{
$this->stderr = '';
ftruncate($this->stderr, 0);
fseek($this->stderr, 0);
$this->incrementalErrorOutputOffset = 0;

return $this;
Expand Down

0 comments on commit 2d931f4

Please sign in to comment.