Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. WindowsPipes.php

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\Pipes

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal