losing STDIN

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am using:

PHP 5.0.4 (cli) (built: Feb 24 2006 16:34:55)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies

I wrote a script which basically sits in a while loop doing:

while (!feof(STDIN)) {
    $line = fgets(STDIN);
    // do something with $line

I pipe a tail command into this script like:

tail -n0 -F /var/log/mystuff.log | php -c /etc/php.ini myscript.php &

Everything works fine until logrotate rotates mystuff.log. Then the  
script just hangs there and no longer processes anything. It doesn't  
seem to drop out of the while loop but I have to put some more debugging  
statements in to see if I can figure out what is going on. Any ideas. I  
don't really get how to deal with feof when the file is rotated.


Re: losing STDIN

*** Karstens Rage escribió/wrote (Wed, 13 Sep 2006 09:37:56 -0700):
Quoted text here. Click to load it

I believe you can configure logrotate to shut down you script and launch it
again. That's what allows, for instance, to get Apache logs rotated. Could
that be a solution?

-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com

Site Timeline