Skip to content

Commit d3b9119

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Add test case for bug #78883
2 parents 1f48b15 + c39b45d commit d3b9119

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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)

0 commit comments

Comments
 (0)