Skip to content

Commit

Permalink
Merge pull request #3 from kamermans/bugfix/null_exit_code
Browse files Browse the repository at this point in the history
Don't exit loop until an exit code is returned
  • Loading branch information
kamermans authored Sep 29, 2017
2 parents 190b97c + 9920624 commit e053a20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @package kamermans\Command
*/
class ProcessManager {

protected $cmd;
protected $buffers;
protected $handle;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function exec($callback, $callbacklines, $buffer_size, $cwd, $env, $conf)
}

$finished_handles = count(array_filter($this->io_reads, 'feof'));
if ($finished_handles === count($this->io_reads)) {
if ($exit_code !== null && $finished_handles === count($this->io_reads)) {
break;
}

Expand Down Expand Up @@ -243,8 +243,8 @@ protected function setupStreams($callback, $callbacklines, $buffer_size)
} else if ($this->isStdInStreaming()) {
// STDIN is streaming to the process
$stdin_stream = new Stream\StreamWriter(
$this->buffers[Command::STDIN],
$this->io_handles[Command::STDIN],
$this->buffers[Command::STDIN],
$this->io_handles[Command::STDIN],
$buffer_size
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Stream/StreamWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function write($auto_close=true)
$this->buffer .= stream_get_contents($this->stream, $this->buffer_size);
}

$bytes_written = fwrite($this->dest_stream, $this->buffer);
$bytes_written = @fwrite($this->dest_stream, $this->buffer);

if ($bytes_written === false) {
return 0;
Expand Down

0 comments on commit e053a20

Please sign in to comment.