#42044 [Opn->Bgs]: stream_select
| From: | jani@php.net | Date: | Thu, 19 Jul 2007 09:23:46 +0000 |
| Subject: | #42044 [Opn->Bgs]: stream_select | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115222@lists.php.net to get a copy of this message | ||
ID: 42044
Updated by: jani@php.net
Reported By: zeusgerde at arcor dot de
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Windows XP
PHP Version: 5.2.3
New Comment:
Remove the @ in front of stream_select() and you'll know why your code
does not work. Also read the manual page for stream_select again:
http://www.php.net/stream_select
Previous Comments:
------------------------------------------------------------------------
[2007-07-19 09:04:40] zeusgerde at arcor dot de
Description:
------------
I try to read from STDIN in the windows console (cmd.exe).
With the code below I get as expected "0" several times until I start
typing.
But when I start typing (not hitting enter) I get "3", all arrays
contain STDIN, STDERR and STDOUT and fread() blocks (of course).
The same happens if I focus on another window with the mouse cursor.
Reproduce code:
---------------
while (1) {
$aException = $aWrite = $aRead = Array(STDIN, STDERR, STDOUT);
$iChangedStreams = @stream_select($aRead, $aWrite, $aException, 1,
0);
echo $iChangedStreams;
if ($iChangedStreams) {
if (in_array(STDIN, $aRead, true)) {
$strBuffer = fread(STDIN, 1);
}
}
}
Expected result:
----------------
$aRead == Array(STDIN);
$aWrite == Array(STDIN, STDOUT, STDERR);
$aException == Array();
/* not sure about STDIN in $aWrite */
Actual result:
--------------
$aRead == Array(STDIN, STDOUT, STDERR);
$aWrite == Array(STDIN, STDOUT, STDERR);
$aException == Array(STDIN, STDOUT, STDERR);
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42044&edit=1