php.net |  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: -
Votes:2
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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marco at m-s-d dot eu
New email:
PHP Version: OS:

 

 [2013-10-10 23:54 UTC] marco at m-s-d dot eu
Description:
------------
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++) {
			$a=array(STDIN);
			$b=NULL;
			$num=stream_select($a,$b,$b,0);
			if($num>0) { //read and discard
			echo "fd '$num'\n";
				echo "'".fread(STDIN,4096)."'";
				break;
			}
			echo "\r".str_repeat(" ",60)."\r";
			echo date("d.m.Y H:i:s") . " still sleeping for ".($secs-$i)." seconds";
			sleep(1);	
		}
		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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 17:01:42 2019 UTC