1--TEST--
2Bug GH-9590 002 (stream_select does not abort upon exception or empty valid fd set)
3--SKIPIF--
4<?php
5if (!function_exists('posix_setrlimit') || !posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1)) {
6    die('skip Failed to set POSIX_RLIMIT_NOFILE');
7}
8?>
9--FILE--
10<?php
11
12posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1);
13
14$fds = [];
15for ($i = 0; $i < 1023; $i++) {
16    $fds[] = @fopen(__DIR__ . "/GH-9590-002-tmpfile.$i", 'w');
17}
18
19list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
20
21set_error_handler(function($errno, $errstr) { throw new \Exception($errstr); });
22
23$r = [$a];
24$w = $e = [];
25var_dump(stream_select($r, $w, $e, PHP_INT_MAX));
26
27?>
28--EXPECTF--
29Fatal error: Uncaught Exception: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE.
30It is set to 1024, but you have descriptors numbered at least as high as %d.
31 --enable-fd-setsize=%d is recommended, but you may want to set it
32to equal the maximum number of open files supported by your system,
33in order to avoid seeing this error again at a later date. in %s:%d
34Stack trace:%a
35--CLEAN--
36<?php
37for ($i = 0; $i < 1023; $i++) {
38    @unlink(__DIR__ . "/GH-9590-002-tmpfile.$i");
39}
40?>
41