Bug #65879 [NEW]: stream_select on STDIN returns 1 even on blocking stream

From: Date: Thu, 10 Oct 2013 23:54:51 +0000
Subject: Bug #65879 [NEW]: stream_select on STDIN returns 1 even on blocking stream
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182123@lists.php.net to get a copy of this message
From:             marco at m-s-d dot eu
Operating system: Windows 7 x64
PHP version:      5.5.4
Package:          Streams related
Bug Type:         Bug
Bug description:stream_select on STDIN returns 1 even on blocking stream

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.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65879&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=65879&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=65879&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=65879&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65879&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65879&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65879&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65879&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65879&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65879&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65879&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=65879&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=65879&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65879&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65879&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65879&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65879&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65879&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65879&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65879&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65879&r=mysqlcfg



Thread (1 message)

  • marco at m-s-d dot eu
« previous php.bugs (#182123) next »