php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24851 fread on popen slow pipe return only part of content
Submitted: 2003-07-29 05:40 UTC Modified: 2003-07-29 05:43 UTC
From: artem at osp dot ru Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.2 OS: Linux 2.2.25
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: artem at osp dot ru
New email:
PHP Version: OS:

 

 [2003-07-29 05:40 UTC] artem at osp dot ru
Description:
------------
on slow pipes opened by popen fread return data to script before length bytes have been read or EOF (end of file) reached.

may be it's not bug, but feature, but in this case, this feature must be documented.

may be it's double #19783

Reproduce code:
---------------
<?php
 ob_implicit_flush(1);
 echo "<b>".date("r")."</b><br>\n";
 $fp=popen('for i in 1 2 3 4 5 6 7 8 9; do echo $i ; sleep 1 ; done',"r");
 while(!feof($fp)) {
  $s=fread($fp,100000);
  echo "<b>".date("r")."</b><pre>$s</pre>\n";
 }
 pclose($fp);
?>


Expected result:
----------------
Tue, 29 Jul 2003 14:27:51 +0400
Tue, 29 Jul 2003 14:27:60 +0400

1
2
3
4
5
6
7
8
9

Actual result:
--------------
Tue, 29 Jul 2003 14:26:01 +0400
Tue, 29 Jul 2003 14:26:01 +0400

1
Tue, 29 Jul 2003 14:26:02 +0400

2
Tue, 29 Jul 2003 14:26:03 +0400

3
Tue, 29 Jul 2003 14:26:04 +0400

4
Tue, 29 Jul 2003 14:26:05 +0400

5
Tue, 29 Jul 2003 14:26:06 +0400

6
Tue, 29 Jul 2003 14:26:07 +0400

7
Tue, 29 Jul 2003 14:26:08 +0400

8
Tue, 29 Jul 2003 14:26:09 +0400

9
Tue, 29 Jul 2003 14:26:10 +0400

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-29 05:43 UTC] wez@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

From:

http://uk.php.net/fread

Note: When reading from network streams or pipes, such as those returned when reading remote files or from popen() and proc_open(), reading will stop after a packet is available. This means that you should collect the data together in chunks as shown in the example below. 


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC