Re: stream_select() not working on regular files?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dennis J. wrote:
> The issue is that once I've hit the EOF I need to continue the loop
> using the stream_select() waiting for new data.

AFAIK you can't; you see stream_select checks to see if something will
be blocked; if EOF is reached it considers this as not blocked; in other
words the second you hit a file EOF stream_select will continue to
instantly return a positive (without the wait of 1 second).

As far as I know every related function will always return the second
EOF is hit; meaning that the -f functionality you want can only be
gained by adding in the sleep (but i think every line reading function
will still instantly return with an empty line) - so maybe you just need
to proc_open to tail -f and read the stream with PHP - as it won't send
an EOF - example:

<?php
$stream = popen( 'tail -f access.log' , 'r' );
while( $line = fgets($stream) ) {
 echo $line;
}
pclose( $stream ); // won't get here unless an error i guess..

good luck!

Nathan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux