File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
ext/standard/tests/streams Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #78883 (fgets(STDIN) fails on Windows)
3
+ --SKIPIF--
4
+ <?php
5
+ if (PHP_OS_FAMILY !== 'Windows ' ) die ('skip this test is for Windows platforms only ' );
6
+ if (getenv ("SKIP_SLOW_TESTS " )) die ("skip slow test " );
7
+ ?>
8
+ --FILE--
9
+ <?php
10
+ $ descriptorspec = array (
11
+ 0 => array ("pipe " , "rb " ),
12
+ 1 => array ("pipe " , "wb " ),
13
+ //2 => array("file", "stderr.txt", "ab")
14
+ );
15
+ $ pipes = [];
16
+ $ cmd = 'cmd.exe "/c START ^"^" /WAIT ' . PHP_BINARY . ' -r ^"var_dump(fgets(STDIN));" ' ;
17
+ $ proc = proc_open ($ cmd , $ descriptorspec , $ pipes );
18
+ var_dump (is_resource ($ proc ));
19
+ $ pid = proc_get_status ($ proc )['pid ' ];
20
+ sleep (1 );
21
+ $ bug_is_present = !proc_get_status ($ proc )['running ' ];
22
+ if (!$ bug_is_present ) {
23
+ // if the bug is not present, it will hang waiting for stdin,
24
+ // thus cmd is still running and we should kill it
25
+ shell_exec ("taskkill /T /F /PID {$ pid }" );
26
+ }
27
+ fclose ($ pipes [0 ]);
28
+ fclose ($ pipes [1 ]);
29
+ proc_close ($ proc );
30
+ var_dump ($ bug_is_present );
31
+ ?>
32
+ --EXPECT--
33
+ bool(true)
34
+ bool(false)
You can’t perform that action at this time.
0 commit comments