Reply to losing STDIN

Your name:

Reply:


Posted by Karstens Rage on 09/13/06 16:37

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.

k

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация