Skip to content

Commit

Permalink
CliRunner: fixed reading of big stdout (closes #69)
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed May 9, 2021
1 parent 47d4c21 commit 96aca96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Runners/CliRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ public function run($cwd, array $args, array $env = NULL)
}

// Reset output and error
stream_set_blocking($pipes[1], false);
stream_set_blocking($pipes[2], false);
$stdout = '';
$stderr = '';

while (TRUE) {
// Read standard output
$stdoutOutput = fgets($pipes[1], 1024);
$stdoutOutput = stream_get_contents($pipes[1]);

if (is_string($stdoutOutput)) {
$stdout .= $stdoutOutput;
}

// Read error output
$stderrOutput = fgets($pipes[2], 1024);
$stderrOutput = stream_get_contents($pipes[2]);

if (is_string($stderrOutput)) {
$stderr .= $stderrOutput;
Expand Down

0 comments on commit 96aca96

Please sign in to comment.