--- /dev/null
+--TEST--\r
+Bug #78883 (fgets(STDIN) fails on Windows)\r
+--SKIPIF--\r
+<?php\r
+if (PHP_OS_FAMILY !== 'Windows') die('skip this test is for Windows platforms only');\r
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");\r
+?>\r
+--FILE--\r
+<?php\r
+$descriptorspec = array(\r
+ 0 => array("pipe", "rb"),\r
+ 1 => array("pipe", "wb"),\r
+ //2 => array("file", "stderr.txt", "ab")\r
+);\r
+$pipes = [];\r
+$cmd = 'cmd.exe "/c START ^"^" /WAIT ' . PHP_BINARY . ' -r ^"var_dump(fgets(STDIN));"';\r
+$proc = proc_open($cmd, $descriptorspec, $pipes);\r
+var_dump(is_resource($proc));\r
+$pid = proc_get_status($proc)['pid'];\r
+sleep(1);\r
+$bug_is_present = !proc_get_status($proc)['running'];\r
+if (!$bug_is_present) {\r
+ // if the bug is not present, it will hang waiting for stdin,\r
+ // thus cmd is still running and we should kill it\r
+ shell_exec("taskkill /T /F /PID {$pid}");\r
+}\r
+fclose($pipes[0]);\r
+fclose($pipes[1]);\r
+proc_close($proc);\r
+var_dump($bug_is_present);\r
+?>\r
+--EXPECT--\r
+bool(true)\r
+bool(false)\r