Bug #66353 [NEW]: fgets unexpected behaviour in non-blocking mode
| From: | an0nym at narod dot ru | Date: | Thu, 26 Dec 2013 10:12:22 +0000 |
| Subject: | Bug #66353 [NEW]: fgets unexpected behaviour in non-blocking mode | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183464@lists.php.net to get a copy of this message | ||
From: an0nym at narod dot ru
Operating system: Linux, BSD
PHP version: 5.5.7
Package: Streams related
Bug Type: Bug
Bug description:fgets unexpected behaviour in non-blocking mode
Description:
------------
In non-blocking mode fgets should buffer data it read from stream until
it meets eol or eof instead of returning anything it read.
Test script:
---------------
$ cat test1.php
<?php
fwrite(STDOUT, 'test1');
sleep(5);
fwrite(STDOUT, "\n");
sleep(5);
fwrite(STDOUT, "test2\n");
$ cat test2.php
<?php
stream_set_blocking(STDIN, false);
do {
$test = fgets(STDIN);
if ($test) {
var_dump($test);
}
} while (!feof(STDIN));
$ php55 test1.php | php55 test2.php
Expected result:
----------------
string(6) "test1
"
string(6) "test2
"
Actual result:
--------------
string(5) "test1"
string(1) "
"
string(6) "test2
"
--
Edit bug report at https://bugs.php.net/bug.php?id=66353&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66353&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66353&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66353&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66353&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66353&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66353&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66353&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66353&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66353&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66353&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66353&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66353&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66353&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66353&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66353&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66353&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66353&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66353&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66353&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66353&r=mysqlcfg