10000 [2.7][Process] Update in 2.7 for stream-based output storage by romainneutron · Pull Request #17424 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.7][Process] Update in 2.7 for stream-based output storage #17424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Process] Use stream based storage to avoid memory issues
  • Loading branch information
romainneutron committed Jan 20, 2016
commit 2d931f43e07435c6d3eb3e145749d800e6cb36db
14 changes: 12 additions & 2 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
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