Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldiron committed Apr 22, 2022
1 parent 4ea9996 commit 843d5a2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static public function execute(string $cmd, string $stdin, string &$stdout, stri
$start = \time();
$stdout = '';
$stderr = '';
$statusPipe = '';
$status = '';

if (\is_resource($process)) {
\stream_set_blocking($pipes[0], false);
Expand All @@ -159,21 +159,19 @@ static public function execute(string $cmd, string $stdin, string &$stdout, stri
while (\is_resource($process)) {
$stdout .= \stream_get_contents($pipes[1]);
$stderr .= \stream_get_contents($pipes[2]);
$statusPipe .= \stream_get_contents($pipes[3]);
$status .= \stream_get_contents($pipes[3]);

if ($timeout > 0 && \time() - $start > $timeout) {
\proc_terminate($process, 9);
return 1;
}

$status = \proc_get_status($process);

if (!$status['running']) {
if (!\proc_get_status($process)['running']) {
\fclose($pipes[1]);
\fclose($pipes[2]);
\proc_close($process);

$exitCode = (int) str_replace("\n","",$statusPipe);
$exitCode = (int) str_replace("\n","",$status);

return $exitCode;
}
Expand Down

0 comments on commit 843d5a2

Please sign in to comment.