|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78883 fgets(STDIN) fails on Windows
Submitted: 2019-11-28 19:23 UTC Modified: 2019-12-03 07:51 UTC
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:4 (100.0%)
From: php at nztm dot net Assigned: cmb (profile)
Status: Closed Package: Streams related
PHP Version: 7.4.0 OS: Windows 10 x64
Private report: No CVE-ID: None
 [2019-11-28 19:23 UTC] php at nztm dot net
On Linux, fgets(STDIN) asks the user for input and returns the results, but this fails on Windows - it immediately returns false. On PHP 7.3 it works on Linux and Windows fine. 

Test script:
var_dump(fgets(STDIN)); // Try on Windows and Linux, PHP 7.4.0


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-28 23:10 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2019-11-28 23:10 UTC]
Thanks for reporting!
 [2019-11-29 07:53 UTC] julien dot boudry at gmail dot com

This happens since 7.4 RC5, working well on RC4 !
 [2019-11-29 08:34 UTC]
> This happens since 7.4 RC5, working well on RC4 !

For me, it fails with RC4 as well.  Apparently, the issue has been
caused by commit 9ec61e4[1], which is shipped as of 7.4.0RC2.

[1] <;a=commit;h=9ec61e43d453aadab9539f6814e8694295aa1ed1>
 [2019-11-29 08:49 UTC] julien dot boudry at gmail dot com
Ok, In fact, I have tested under higer level code, so probably you are right. ( . This one, I'm sur 100% it's RC5 on two differents Windows 10 up to date installation.

I will try to switch on RC4 and tell you if it's working. If I not answer, consider that you are right.
 [2019-11-29 12:08 UTC]
The behavioral change has been introduced with commit d05deaa[1],
which has been squashed in to the commit mentioned above.  That
change is necessary to avoid that ftell() gets called on character
files, which would render the return value to be undefined[2].
What has been missed in this commit, is to properly adjust
self->is_pipe_blocking (which is a Windows only flag), to avoid
calling PeekNamedPipe() on characters files, which is not

[1] <>
[2] <>
[3] <>
 [2019-11-29 12:18 UTC]
The following pull request has been associated:

Patch Name: Fix #78883: fgets(STDIN) fails on Windows
On GitHub:
 [2019-12-02 15:54 UTC]
Automatic comment on behalf of
Log: Fix #78883: fgets(STDIN) fails on Windows
 [2019-12-02 15:54 UTC]
-Status: Verified +Status: Closed
 [2019-12-03 07:51 UTC]
Windows snapshots containing the fix for this bug are available at
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 15:01:28 2024 UTC