[Process] Wait a bit less on Windows
This commit is contained in:
parent
b228378d1f
commit
380a54f987
@ -102,7 +102,7 @@ class UnixPipes extends AbstractPipes
|
||||
unset($r[0]);
|
||||
|
||||
// let's have a look if something changed in streams
|
||||
if ($r && false === $n = @stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
|
||||
if (($r || $w) && false === $n = @stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
|
||||
// if a system call has been interrupted, forget about it, let's try again
|
||||
// otherwise, an error occurred, let's reset pipes
|
||||
if (!$this->hasSystemCallBeenInterrupted()) {
|
||||
|
@ -106,12 +106,16 @@ class WindowsPipes extends AbstractPipes
|
||||
public function readAndWrite($blocking, $close = false)
|
||||
{
|
||||
$this->unblock();
|
||||
$this->write();
|
||||
$w = $this->write();
|
||||
$read = $r = $e = array();
|
||||
|
||||
$read = array();
|
||||
if ($this->fileHandles && $blocking) {
|
||||
if ($blocking) {
|
||||
if ($w) {
|
||||
@stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
|
||||
} elseif ($this->fileHandles) {
|
||||
usleep(Process::TIMEOUT_PRECISION * 1E6);
|
||||
}
|
||||
}
|
||||
foreach ($this->fileHandles as $type => $fileHandle) {
|
||||
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
|
||||
|
||||
|
@ -360,8 +360,7 @@ class Process
|
||||
do {
|
||||
$this->checkTimeout();
|
||||
$running = '\\' === DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
|
||||
$close = '\\' !== DIRECTORY_SEPARATOR || !$running;
|
||||
$this->readPipes(true, $close);
|
||||
$this->readPipes($running, '\\' !== DIRECTORY_SEPARATOR || !$running);
|
||||
} while ($running);
|
||||
|
||||
while ($this->isRunning()) {
|
||||
@ -1295,14 +1294,15 @@ class Process
|
||||
}
|
||||
|
||||
$this->processInformation = proc_get_status($this->process);
|
||||
$running = $this->processInformation['running'];
|
||||
|
||||
$this->readPipes($blocking, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true);
|
||||
$this->readPipes($running && $blocking, '\\' !== DIRECTORY_SEPARATOR || !$running);
|
||||
|
||||
if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
$this->processInformation = $this->fallbackStatus + $this->processInformation;
|
||||
}
|
||||
|
||||
if (!$this->processInformation['running']) {
|
||||
if (!$running) {
|
||||
$this->close();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user