[svlug] select/poll and EOF

Steve Hindle steve at itsage.com
Thu Aug 14 23:03:07 PDT 2003

Not sure about this on Linux - but there is an async I/O option in most 
unices.  Not sure about EOF semantics. You 'register' a callback function 
that is called when data becomes available.


--On Friday, August 15, 2003 4:51 AM +0000 "M. Drew Streib" 
<dtype at dtype.org> wrote:

> Another question...
> I need to implement something similar to 'tail -f' although it needs
> to have millisecond accuracy.
> select() and poll() both return on a file EOF, because read() will not
> block. I need to either get one of them to not return on an EOF, but
> rather when there is actual data to read, or accomplish the same thing
> in another manner.
> This question has been asked and badly answered on lkml before. (Not
> a real answer, only an explanation of why select() does what it does.
> I know what it does, dammit. :) I need to know how to get something
> else done. heh.)
> It turns out GNU tail just cheeses things and only checks the file
> descriptor once per second for changes. In my case, this won't work
> well as I'd like to know when data is available immediately.
> My only recourse now is to basically sleep for some fraction of a
> second and then do a read() to see what returns. The more accurate
> I want to get, though, the more I send the cpu(s) into frantic cycles
> for no reason.
> Any ideas? I'm beginning to think I'm just SOL.
> -drew
> --
> M. Drew Streib <dtype at dtype.org>
> Independent Rambler, Software/Standards/Freedom/Law -- http://dtype.org/

Stephen Hindle
I.T. Sage
"Enlightened Solutions for Open Minds"

More information about the svlug mailing list