File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
ext/standard/tests/streams Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug #34380: stream_socket_pair should set posix_globals.last_error on failure
3+ --SKIPIF--
4+ <?php
5+ if ( substr (PHP_OS , 0 , 3 ) == "WIN " )
6+ die ("skip. Do not run on Windows " );
7+ ?>
8+ --FILE--
9+ <?php
10+
11+ // invalid type to force EOPNOTSUPP (only STREAM_PF_UNIX is supported on *nix)
12+ $ sockets = stream_socket_pair (STREAM_PF_INET , STREAM_SOCK_STREAM , STREAM_IPPROTO_IP );
13+ var_dump ($ sockets );
14+ var_dump (posix_get_last_error ());
15+ ?>
16+ --EXPECTF--
17+
18+ Warning: stream_socket_pair(): failed to create sockets: [95]: Operation not supported in %s on line %d
19+ bool(false)
20+ int(95)
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug #34380: stream_select should set posix_globals.last_error on failure
3+ --SKIPIF--
4+ <?php
5+ if ( substr (PHP_OS , 0 , 3 ) == "WIN " )
6+ die ("skip. Do not run on Windows " );
7+ ?>
8+ --FILE--
9+ <?php
10+
11+ function handler ($ signo ) {}
12+ pcntl_signal (SIGUSR2 , "handler " );
13+
14+ $ pid = pcntl_fork ();
15+ if ($ pid == -1 ) {
16+ die ('could not fork ' );
17+ } else if ($ pid ) {
18+ // hack: a stream that will not show a ready event immediately (STDIN for write)
19+ $ w = Array (STDIN );
20+ $ e = NULL ;
21+
22+ // should get EINTR after child sends us a signal
23+ $ fds = stream_select ($ e , $ r , $ e , 60 );
24+ var_dump ($ fds );
25+ var_dump (posix_get_last_error ());
26+ } else {
27+ // racy
28+ sleep (2 );
29+ posix_kill (posix_getppid (), SIGUSR2 );
30+ }
31+ ?>
32+ --EXPECTF--
33+
34+ Warning: stream_select(): unable to select [4]: Interrupted system call (max_fd=0) in %s on line %d
35+ bool(false)
36+ int(4)
You can’t perform that action at this time.
0 commit comments