public function __construct($ttyMode, $ptyMode, $input, $disableOutput) { $this->ttyMode = (bool) $ttyMode; $this->ptyMode = (bool) $ptyMode; $this->disableOutput = (bool) $disableOutput; parent::__construct($input); }
public function __construct($ttyMode, $ptyMode, $input, $haveReadSupport) { $this->ttyMode = (bool) $ttyMode; $this->ptyMode = (bool) $ptyMode; $this->haveReadSupport = (bool) $haveReadSupport; parent::__construct($input); }
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 $pipes = array(Process::STDOUT => Process::OUT, Process::STDERR => Process::ERR); $tmpDir = sys_get_temp_dir(); if (!@fopen($file = $tmpDir . '\\sf_proc_00.check', 'wb')) { throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable'); } @unlink($file); for ($i = 0;; ++$i) { foreach ($pipes as $pipe => $name) { $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name); if (file_exists($file) && !@unlink($file)) { continue 2; } $h = @fopen($file, 'xb'); if (!$h || !($this->fileHandles[$pipe] = fopen($file, 'rb'))) { continue 2; } if (isset($this->files[$pipe])) { @unlink($this->files[$pipe]); } $this->files[$pipe] = $file; } break; } } parent::__construct($input); }
public function __construct($input, $haveReadSupport) { $this->haveReadSupport = (bool) $haveReadSupport; if ($this->haveReadSupport) { // 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'); } } } parent::__construct($input); }
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 $pipes = array(Process::STDOUT => Process::OUT, Process::STDERR => Process::ERR); $tmpCheck = false; $tmpDir = sys_get_temp_dir(); $lastError = 'unknown reason'; set_error_handler(function ($type, $msg) use(&$lastError) { $lastError = $msg; }); for ($i = 0;; ++$i) { foreach ($pipes as $pipe => $name) { $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name); if (file_exists($file) && !unlink($file)) { continue 2; } $h = fopen($file, 'xb'); if (!$h) { $error = $lastError; if ($tmpCheck || ($tmpCheck = unlink(tempnam(false, 'sf_check_')))) { continue; } restore_error_handler(); throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $error)); } if (!$h || !($this->fileHandles[$pipe] = fopen($file, 'rb'))) { continue 2; } if (isset($this->files[$pipe])) { unlink($this->files[$pipe]); } $this->files[$pipe] = $file; } break; } restore_error_handler(); } parent::__construct($input); }