php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41201 fgets($stdin) does not return after newline if $stdin is filtered
Submitted: 2007-04-26 13:24 UTC Modified: 2008-07-21 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: rganogork at gmail dot com Assigned: pollita (profile)
Status: No Feedback Package: Streams related
PHP Version: 5.2.1 OS: Gentoo Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rganogork at gmail dot com
New email:
PHP Version: OS:

 

 [2007-04-26 13:24 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-15 21:11 UTC] 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()...
 [2008-07-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC