Skip to content

Commit e053a20

Browse files
authored
Merge pull request #3 from kamermans/bugfix/null_exit_code
Don't exit loop until an exit code is returned
2 parents 190b97c + 9920624 commit e053a20

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/ProcessManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @package kamermans\Command
99
*/
1010
class ProcessManager {
11-
11+
1212
protected $cmd;
1313
protected $buffers;
1414
protected $handle;
@@ -74,7 +74,7 @@ public function exec($callback, $callbacklines, $buffer_size, $cwd, $env, $conf)
7474
}
7575

7676
$finished_handles = count(array_filter($this->io_reads, 'feof'));
77-
if ($finished_handles === count($this->io_reads)) {
77+
if ($exit_code !== null && $finished_handles === count($this->io_reads)) {
7878
break;
7979
}
8080

@@ -243,8 +243,8 @@ protected function setupStreams($callback, $callbacklines, $buffer_size)
243243
} else if ($this->isStdInStreaming()) {
244244
// STDIN is streaming to the process
245245
$stdin_stream = new Stream\StreamWriter(
246-
$this->buffers[Command::STDIN],
247-
$this->io_handles[Command::STDIN],
246+
$this->buffers[Command::STDIN],
247+
$this->io_handles[Command::STDIN],
248248
$buffer_size
249249
);
250250
} else {

src/Stream/StreamWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function write($auto_close=true)
5555
$this->buffer .= stream_get_contents($this->stream, $this->buffer_size);
5656
}
5757

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

6060
if ($bytes_written === false) {
6161
return 0;

0 commit comments

Comments
 (0)