@@ -48,7 +48,7 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
4848
4949 // ensure resource is opened for reading (fopen mode must contain "r" or "+")
5050 $ meta = \stream_get_meta_data ($ stream );
51- if (isset ( $ meta [ ' mode ' ]) && $ meta [ ' mode ' ] !== '' && \strpos ($ meta ['mode ' ], 'r ' ) === \strpos ($ meta ['mode ' ], '+ ' )) {
51+ if (\strpos ($ meta ['mode ' ], 'r ' ) === \strpos ($ meta ['mode ' ], '+ ' )) {
5252 throw new InvalidArgumentException ('Given stream resource is not opened in read mode ' );
5353 }
5454
@@ -61,14 +61,9 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
6161 // Use unbuffered read operations on the underlying stream resource.
6262 // Reading chunks from the stream may otherwise leave unread bytes in
6363 // PHP's stream buffers which some event loop implementations do not
64- // trigger events on (edge triggered).
65- // This does not affect the default event loop implementation (level
66- // triggered), so we can ignore platforms not supporting this (HHVM).
67- // Pipe streams (such as STDIN) do not seem to require this and legacy
68- // PHP versions cause SEGFAULTs on unbuffered pipe streams, so skip this.
69- if (\function_exists ('stream_set_read_buffer ' ) && !$ this ->isLegacyPipe ($ stream )) {
70- \stream_set_read_buffer ($ stream , 0 );
71- }
64+ // trigger events on (edge triggered). This does not affect the default
65+ // event loop implementation (level triggered).
66+ \stream_set_read_buffer ($ stream , 0 );
7267
7368 $ this ->stream = $ stream ;
7469 $ this ->loop = $ loop ?: Loop::get ();
@@ -152,28 +147,4 @@ public function handleData()
152147 $ this ->close ();
153148 }
154149 }
155-
156- /**
157- * Returns whether this is a pipe resource in a legacy environment
158- *
159- * This works around a legacy PHP bug (#61019) that was fixed in PHP 5.4.28+
160- * and PHP 5.5.12+ and newer.
161- *
162- * @param resource $resource
163- * @return bool
164- * @link https://github.com/reactphp/child-process/issues/40
165- *
166- * @codeCoverageIgnore
167- */
168- private function isLegacyPipe ($ resource )
169- {
170- if (\PHP_VERSION_ID < 50428 || (\PHP_VERSION_ID >= 50500 && \PHP_VERSION_ID < 50512 )) {
171- $ meta = \stream_get_meta_data ($ resource );
172-
173- if (isset ($ meta ['stream_type ' ]) && $ meta ['stream_type ' ] === 'STDIO ' ) {
174- return true ;
175- }
176- }
177- return false ;
178- }
179150}
0 commit comments