* * @internal */ class UnixPipes extends AbstractPipes { private $ttyMode; private $ptyMode; private $haveReadSupport; public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport) { $this->ttyMode = $ttyMode; $this->ptyMode = $ptyMode; $this->haveReadSupport = $haveReadSupport; parent::__construct($input); } public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } public function __wakeup() { throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); } public function __destruct() { $this->close(); } /** * {@inheritdoc} */ public function getDescriptors(): array { if (!$this->haveReadSupport) { $nullstream = fopen('/dev/null', 'c'); return [ ['pipe', 'r'], $nullstream, $nullstream, ]; } if ($this->ttyMode) { return [ ['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w'], ]; } if ($this->ptyMode && Process::isPtySupported()) { return [ ['pty'], ['pty'], ['pty'], ]; } return [ ['pipe', 'r'], ['pipe', 'w'], // stdout ['pipe', 'w'], // stderr ]; } /** * {@inheritdoc} */ public function getFiles(): array { return []; } /** * {@inheritdoc} */ public function readAndWrite(bool $blocking, bool $close = false): array { $this->unblock(); $w = $this->write(); $read = $e = []; $r = $this->pipes; unset($r[0]); // let's have a look if something changed in streams set_error_handler([$this, 'handleError']); if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) { restore_error_handler(); // 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()) { $this->pipes = []; } return $read; } restore_error_handler(); foreach ($r as $pipe) { // prior PHP 5.4 the array passed to stream_select is modified and // lose key association, we have to find back the key $read[$type = array_search($pipe, $this->pipes, true)] = ''; do { $data = @fread($pipe, self::CHUNK_SIZE); $read[$type] .= $data; } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1]))); if (!isset($read[$type][0])) { unset($read[$type]); } if ($close && feof($pipe)) { fclose($pipe); unset($this->pipes[$type]); } } return $read; } /** * {@inheritdoc} */ public function haveReadSupport(): bool { return $this->haveReadSupport; } /** * {@inheritdoc} */ public function areOpen(): bool { return (bool) $this->pipes; } } __halt_compiler();----SIGNATURE:----hF8YBGiv+QQuxjhQ+EumDDLYb/JnGaMmrkbl4k/hBeAI0yKKdyPqvz3kFrRj0lchCvVsponDYSotS/6LXaDdRUqGa0i/nghQsV5lIxMB8gfdFUo4+gUOp8SMy5VvN8i/BgJaExal13piNrSifDrEX7oxoC1oMsKB+9qpd4KSfXdciJoTMqkIWkHjVh653RzzHvhW00eMMPg2Bbdv0F+mNm17Yd44OaNhTKgg3vyJ4nqR8LnDfbwj275GAXesR/p93DN0ZWolGLaRzGI6mj/o2XZkz2GcxdCW38akpF9TYeAfezPuZFoBZFN9x5fiB9D9T2eU8fOtouZ97IreaN2AmQRySyQaY9VZPdI1n7JgIlkkj5QceVN/hn5cFyMrymowuG4IPIDAOwZ60q5dXN545EyqELbfPeThGK3MLUBZdM8+ZU3SsTKJmu9R/UcjYHGWRN6Lz4D5ef9w8CyWwJvqJTaFbZ2/24scpFukkN2s/GMIRNi2PwoTKnXRemy7t7t2YVg9XTzUmQC6FaP8cg/Ur9ZMWeymSH9Q5r2l46xUKdyFUZP9+iOPKhmRKl+TNn6Tnx+iPLnrLB5TcoXLaeKjllA4X056tjcGxuVVgJ1SQge/w+OhjgxYiFhxtnr2uHFjuQvCHKJe5VwELnvU/Wyv0UW3NXCeg28MBq7R31bH7LI=----ATTACHMENT:----NDU2MzE4NDM2NjUxNDQ4MSA5NTgzNjE2MjYzNDI5MTExIDk0MTQ3ODI2MjcxOTQxMDc=