Skip to content

Commit 070dace

Browse files
Merge pull request #8 from pvandommelen
Consume output pipes while running the ProcOpen process.
2 parents 984c59b + c8dd53c commit 070dace

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Processor/ProcOpen.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ public function run(string $cmd, array $acceptableExitCodes = [0]): Result
4747
}
4848

4949
// Loop on process until it exits normally.
50+
$stdOut = "";
51+
$stdErr = "";
5052
do {
53+
// Consume output streams while the process runs. The buffer will block process updates when full
5154
$status = proc_get_status($process);
55+
$stdOut .= stream_get_contents($pipes[1]);
56+
$stdErr .= stream_get_contents($pipes[2]);
5257
} while ($status && $status['running']);
5358

5459
$code = $status['exitcode'] ?? -1;
55-
$stdOut = stream_get_contents($pipes[1]);
56-
$stdErr = stream_get_contents($pipes[2]);
5760

5861
// make sure all pipes are closed before calling proc_close
5962
foreach ($pipes as $index => $pipe) {

0 commit comments

Comments
 (0)