1--TEST--
2Bug #78883 (fgets(STDIN) fails on Windows)
3--SKIPIF--
4<?php
5if (PHP_OS_FAMILY !== 'Windows') die('skip this test is for Windows platforms only');
6if (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);
18var_dump(is_resource($proc));
19$pid = proc_get_status($proc)['pid'];
20sleep(3);
21$bug_is_present = !proc_get_status($proc)['running'];
22if (!$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} 2>nul");
26}
27fclose($pipes[0]);
28fclose($pipes[1]);
29proc_close($proc);
30var_dump($bug_is_present);
31?>
32--EXPECT--
33bool(true)
34bool(false)
35