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