|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65879 stream_select on STDIN returns 1 even on blocking stream
Submitted: 2013-10-10 23:54 UTC Modified: -
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: marco at m-s-d dot eu Assigned:
Status: Open Package: Streams related
PHP Version: 5.5.4 OS: Windows 7 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
24 + 29 = ?
Subscribe to this entry?

 [2013-10-10 23:54 UTC] marco at m-s-d dot eu
When doing a stream_select(STDIN,null,null,0), then the return value will be 1 as soon as one switches the window focus or presses a meta key, but a subsequent fread(STDIN) will block.

This is possible the same problem as #42044, which was closed as not a bug - however, I deem this behaviour as a bug as the select() is supposed to make sure a fread() will NOT block!

Test script:
public static function sleep($secs) {
		echo "sleeping $secs s";
		for($i=0;$i<$secs;$i++) {
			if($num>0) { //read and discard
			echo "fd '$num'\n";
				echo "'".fread(STDIN,4096)."'";
			echo "\r".str_repeat(" ",60)."\r";
			echo date("d.m.Y H:i:s") . " still sleeping for ".($secs-$i)." seconds";
		echo "done sleeping\n";

Expected result:
The sleep counter is supposed to keep on counting in the background even if the commandline window is not focused.

Actual result:
The display will be e.g. "sleeping 20 sfd '1'" after focusing away.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri May 29 21:01:25 2020 UTC