function WindowsPipes::readAndWrite
Overrides PipesInterface::readAndWrite
File
-
vendor/
symfony/ process/ Pipes/ WindowsPipes.php, line 132
Class
- WindowsPipes
- WindowsPipes implementation uses temporary files as handles.
Namespace
Symfony\Component\Process\PipesCode
public function readAndWrite(bool $blocking, bool $close = false) : array {
$this->unblock();
$w = $this->write();
$read = $r = $e = [];
if ($blocking) {
if ($w) {
@stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1000000.0);
}
elseif ($this->fileHandles) {
usleep((int) (Process::TIMEOUT_PRECISION * 1000000.0));
}
}
foreach ($this->fileHandles as $type => $fileHandle) {
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
if (isset($data[0])) {
$this->readBytes[$type] += \strlen($data);
$read[$type] = $data;
}
if ($close) {
ftruncate($fileHandle, 0);
fclose($fileHandle);
flock($this->lockHandles[$type], \LOCK_UN);
fclose($this->lockHandles[$type]);
unset($this->fileHandles[$type], $this->lockHandles[$type]);
}
}
return $read;
}