Re: stream_select() not working on regular files?

From: Date: Thu, 04 Feb 2010 15:09:54 +0000
Subject: Re: stream_select() not working on regular files?
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-301819@lists.php.net to get a copy of this message
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

« previous php.general (#301819) next »