You are here

public function WindowsPipes::__construct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/process/Pipes/WindowsPipes.php \Symfony\Component\Process\Pipes\WindowsPipes::__construct()

File

vendor/symfony/process/Pipes/WindowsPipes.php, line 41

Class

WindowsPipes
WindowsPipes implementation uses temporary files as handles.

Namespace

Symfony\Component\Process\Pipes

Code

public function __construct($disableOutput, $input) {
  $this->disableOutput = (bool) $disableOutput;
  if (!$this->disableOutput) {

    // Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big.
    // Workaround for this problem is to use temporary files instead of pipes on Windows platform.
    //
    // @see https://bugs.php.net/bug.php?id=51800
    $this->files = array(
      Process::STDOUT => tempnam(sys_get_temp_dir(), 'out_sf_proc'),
      Process::STDERR => tempnam(sys_get_temp_dir(), 'err_sf_proc'),
    );
    foreach ($this->files as $offset => $file) {
      if (false === $file || false === ($this->fileHandles[$offset] = fopen($file, 'rb'))) {
        throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
      }
    }
  }
  if (is_resource($input)) {
    $this->input = $input;
  }
  else {
    $this->inputBuffer = $input;
  }
}