#21120 [Fbk->]: fflush doesn`t work
| From: | wez@php.net | Date: | Sun, 22 Dec 2002 15:02:20 +0000 |
| Subject: | #21120 [Fbk->]: fflush doesn`t work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-28188@lists.php.net to get a copy of this message | ||
ID: 21120
Updated by: wez@php.net
Reported By: rashid@php.net
-Status: Feedback
+Status: Won\'t fix
Bug Type: Filesystem function related
Operating System: win2k pro
PHP Version: 4.2.3
New Comment:
More of a "can't fix".
PHP is fflush()ing correctly, which merely causes any data buffered in
a FILE* to be sent to the OS at that time.
It is up to the OS to decide when to write the data to disk.
If you sleep(1) after the fflush() call, the script works as you
described, at least on my WinXP box.
Previous Comments:
------------------------------------------------------------------------
[2002-12-21 13:19:13] rashid@ds.pg.gda.pl
no changes with latest windows build (PHP Version 4.4.0-dev)
------------------------------------------------------------------------
[2002-12-21 12:10:59] iliaa@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
------------------------------------------------------------------------
[2002-12-20 16:01:39] rashid@php.net
this is not the same as
http://bugs.php.net/bug.php?id=19711 :)
the following code on my platform displays:
File size: 0, written: 2890
File size: 2890, written: 2890
as far as i know fflush should flush output to file at the moment of
calling :] moving the line with flcose to the end of script causes that
also the second display shows
File size: 0, written: 2890
it looks for me that fflush doesn`t work and all flushing is done
during file closing.
tested it under linux also - both variants are done ok there:
File size: 2890, written: 2890
File size: 2890, written: 2890
$str = '';
for($i = 0;$i < 1000;$i++) {
$str .= $i;
}
$fp = fopen('test.txt', 'wb');
$written = fwrite($fp, $str);
fflush($fp);
clearstatcache();
$size = filesize('test.txt');
echo 'File size: '.$size.', written: '.$written.'<br>';
fclose($fp);
clearstatcache();
$size = filesize('test.txt');
echo 'File size: '.$size.', written: '.$written.'<br>';
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21120&edit=1