|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-04-27 21:36 UTC] lew at mailduct dot com
Description: ------------ In my prior bug report #25649 from September 2003, I pointed out a serious bug in how PHP handles FEOF under FreeBSD. It was fixed by [email protected] and committed. This same problem (improper handling of feof() by PHP under FreeBSD) has now crept into current 4.3.X versions of PHP... Problem: Once set, the FEOF indicator is not properly cleared when more data is appended to a file that is opened for read by a PHP application. Example: Suppose I want to "tail" a file using PHP. Once I hit the EOF, I will no longer be able to read data from that file even when another application appends to it. This is not the correct behaviour for feof(), as illustrated by the prior fix done by [email protected]. Reproduce code: --------------- --- program: $fp = fopen( '/var/log/maillog','r' ); while( TRUE ) { $r = array( $fp ); $n = stream_select( $r,$w=NULL,$e=NULL,30 ); if( $n ) { echo fgets( $fp ); } } --- feeder: echo "This is a test..." >> /var/log/maillog Expected result: ---------------- For as long as PROGRAM is running, each time I run FEEDER I expect to see PROGRAM output "This is a test..." but it does not, because once EOF is reached, it is not properly reset upon more data being appended to the file. See pr #25649 for historical info... Actual result: -------------- PROGRAM will read the contents of /var/log/maillog until it reaches EOF, and will not output anything else, even if new data is appeneded to the file. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Jan 01 16:00:01 2026 UTC |
Tested on Fedora4 Linux XXXX 2.6.11-1.1369_FC4smp #1 SMP Thu Jun 2 23:08:39 EDT 2005 i686 i686 i386 GNU/Linux php 5.2.5 compiled without SSL (--openssl) Reproduce code: #!/usr/local/bin/php <?php $file = "/tmp/maillog"; $fp = @fopen($file, 'r'); if (!$fp) die ("Could not open $file"); while (true) { $r = array($fp); $n = stream_select($r, $w = null, $e = null, 30); if ($n) { echo fgets($fp); } } Still an issue in php5.2.x. Stephen