Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
UnixPipes.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\Process\Pipes;
013
014 use Symfony\Component\Process\Process;
015
016 /**
017 * UnixPipes implementation uses unix pipes as handles.
018 *
019 * @author Romain Neutron <imprec@gmail.com>
020 *
021 * @internal
022 */
023 class UnixPipes extends AbstractPipes
024 {
025 private $ttyMode;
026 private $ptyMode;
027 private $haveReadSupport;
028
029 public function __construct($ttyMode, $ptyMode, $input, $haveReadSupport)
030 {
031 $this->ttyMode = (bool) $ttyMode;
032 $this->ptyMode = (bool) $ptyMode;
033 $this->haveReadSupport = (bool) $haveReadSupport;
034
035 parent::__construct($input);
036 }
037
038 public function __destruct()
039 {
040 $this->close();
041 }
042
043 /**
044 * {@inheritdoc}
045 */
046 public function getDescriptors()
047 {
048 if (!$this->haveReadSupport) {
049 $nullstream = fopen('/dev/null', 'c');
050
051 return [
052 ['pipe', 'r'],
053 $nullstream,
054 $nullstream,
055 ];
056 }
057
058 if ($this->ttyMode) {
059 return [
060 ['file', '/dev/tty', 'r'],
061 ['file', '/dev/tty', 'w'],
062 ['file', '/dev/tty', 'w'],
063 ];
064 }
065
066 if ($this->ptyMode && Process::isPtySupported()) {
067 return [
068 ['pty'],
069 ['pty'],
070 ['pty'],
071 ];
072 }
073
074 return [
075 ['pipe', 'r'],
076 ['pipe', 'w'], // stdout
077 ['pipe', 'w'], // stderr
078 ];
079 }
080
081 /**
082 * {@inheritdoc}
083 */
084 public function getFiles()
085 {
086 return [];
087 }
088
089 /**
090 * {@inheritdoc}
091 */
092 public function readAndWrite($blocking, $close = false)
093 {
094 $this->unblock();
095 $w = $this->write();
096
097 $read = $e = [];
098 $r = $this->pipes;
099 unset($r[0]);
100
101 // let's have a look if something changed in streams
102 set_error_handler([$this, 'handleError']);
103 if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
104 restore_error_handler();
105 // if a system call has been interrupted, forget about it, let's try again
106 // otherwise, an error occurred, let's reset pipes
107 if (!$this->hasSystemCallBeenInterrupted()) {
108 $this->pipes = [];
109 }
110
111 return $read;
112 }
113 restore_error_handler();
114
115 foreach ($r as $pipe) {
116 // prior PHP 5.4 the array passed to stream_select is modified and
117 // lose key association, we have to find back the key
118 $read[$type = array_search($pipe, $this->pipes, true)] = '';
119
120 do {
121 $data = @fread($pipe, self::CHUNK_SIZE);
122 $read[$type] .= $data;
123 } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
124
125 if (!isset($read[$type][0])) {
126 unset($read[$type]);
127 }
128
129 if ($close && feof($pipe)) {
130 fclose($pipe);
131 unset($this->pipes[$type]);
132 }
133 }
134
135 return $read;
136 }
137
138 /**
139 * {@inheritdoc}
140 */
141 public function haveReadSupport()
142 {
143 return $this->haveReadSupport;
144 }
145
146 /**
147 * {@inheritdoc}
148 */
149 public function areOpen()
150 {
151 return (bool) $this->pipes;
152 }
153 }
154