Skip to content

Commit bc0bca9

Browse files
committed
Do not suppress warnings for invalid streams in stream_select()
1 parent e69a8bd commit bc0bca9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/StreamSelectLoop.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,15 @@ private function streamSelect(array &$read, array &$write, $timeout)
287287
}
288288
}
289289

290-
// suppress warnings that occur, when stream_select is interrupted by a signal
291-
$ret = @\stream_select($read, $write, $except, $timeout === null ? null : 0, $timeout);
290+
// suppress warnings that occur when `stream_select()` is interrupted by a signal
291+
\set_error_handler(function ($errno, $errstr) {
292+
$eintr = \defined('SOCKET_EINTR') ? \SOCKET_EINTR : 4;
293+
return ($errno === \E_WARNING && \strpos($errstr, '[' . $eintr .']: ') !== false);
294+
});
295+
296+
$ret = \stream_select($read, $write, $except, $timeout === null ? null : 0, $timeout);
297+
298+
\restore_error_handler();
292299

293300
if ($except) {
294301
$write = \array_merge($write, $except);

0 commit comments

Comments
 (0)