From:             final at solnet dot ch
Operating system: SuSE Linux 8.2
PHP version:      4.3.3
PHP Bug Type:     Filesystem function related
Bug description:  filemtime-problem

Description:
------------
ok, i've written a "watcher-tool" for my /var/log/mail, which is a
syslog-file (for pop-before-smtp with sendmail, but this doesn't matter).
i have a never ending do-while with a sleep of 4 seconds, and i use
filemtime to see if something changed in /var/log/mail. well, the problem
was, the script never went through even if the file got changed (i've
checked that with ls -l many times...). only if you get filemtime of
another file between two filemtimes of /var/log/mail, php noticed that the
file modification time changed.

well, but if you edit the file by an editor, php does notice it. first i
thought, its a matter of syslog-daemon, but since i tried to use filemtime
on another file between two checks of /var/log/mail, im not sure
anymore...

Reproduce code:
---------------
#!/usr/local/php/bin/php
<?php
$file = "/var/log/mail";
$filemtime = filemtime($file);
do
{
        sleep(3);
        echo "not out yet!";
} while (filemtime($file) == $filemtime);
// you'll never get out, even if the log-file gets changed :)
echo "im out (but this will never happen :p)";
?>

Expected result:
----------------
Get out of do ... while as soon as sendmail/postfix/qpopper/ipopd/whatever
writes something to your /var/log/mail

Actual result:
--------------
you won't get out :p

-- 
Edit bug report at http://bugs.php.net/?id=26011&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26011&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26011&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26011&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26011&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26011&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26011&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26011&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26011&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26011&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26011&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26011&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26011&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26011&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26011&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26011&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26011&r=float

Reply via email to