Re: [PHP] stream_select() not working on regular files?

[email protected] (Nathan Rixham)
Newsgroups php.general
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.