#41201 [Asn->Fbk]: fgets($stdin) does not return after newline if $stdin is filtered
| From: | jani@php.net | Date: | Sun, 13 Jul 2008 16:08:21 +0000 |
| Subject: | #41201 [Asn->Fbk]: fgets($stdin) does not return after newline if $stdin is filtered | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-126620@lists.php.net to get a copy of this message | ||
ID: 41201
Updated by: jani@php.net
Reported By: rganogork at gmail dot com
-Status: Assigned
+Status: Feedback
Bug Type: Streams related
Operating System: Gentoo Linux
PHP Version: 5.2.1
Assigned To: pollita
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Previous Comments:
------------------------------------------------------------------------
[2007-11-15 21:11:43] tvdijen at planet dot nl
I have the exact same problem on Windows XP, PHP 5.2.4
The same thing seems to happen with fread()...
------------------------------------------------------------------------
[2007-04-26 13:24:55] rganogork at gmail dot com
Description:
------------
If the input stream is filtered then fgets($stdin) does not return when
newline is typed.
Reproduce code:
---------------
<?php
class test_filter extends php_user_filter {
public function filter($in, $out, &$consumed, $closing) {
while ($bucket = stream_bucket_make_writeable($in)) {
$bucket->data = strtoupper($bucket->data);
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
}
}
$stdin = fopen("php://stdin", "r");
stream_filter_register("test.23", "test_filter");
stream_filter_append($stdin, "test.23");
fgets($stdin);
?>
Expected result:
----------------
Should return after newline. It does return if you comment the 2
stream... lines.
Actual result:
--------------
It hangs, probably waiting for more input.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41201&edit=1