Skip to content

Commit 09e76cb

Browse files
committed
Add test case for bug #78883
The actual test has been provided by divinity76.
1 parent 4f0e5c8 commit 09e76cb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 = proc_open('cmd.exe "/c START ^"^" /WAIT php -r ^"var_dump(fgets(STDIN));"', $descriptorspec, $pipes);
17+
var_dump(is_resource($cmd));
18+
$cmdpid = proc_get_status($cmd)['pid'];
19+
sleep(1);
20+
$bug_is_present = !proc_get_status($cmd)['running'];
21+
if (!$bug_is_present) {
22+
// if the bug is not present, it will hang waiting for stdin,
23+
// thus cmd is still running and we should kill it
24+
shell_exec("taskkill /T /F /PID {$cmdpid}");
25+
}
26+
fclose($pipes[0]);
27+
fclose($pipes[1]);
28+
proc_close($cmd);
29+
var_dump($bug_is_present);
30+
?>
31+
--EXPECT--
32+
bool(true)
33+
bool(false)

0 commit comments

Comments
 (0)