[svlug] select/poll and EOF

M. Drew Streib dtype at dtype.org
Thu Aug 14 21:51:03 PDT 2003


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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.svlug.org/archives/svlug/attachments/20030815/e9d692a3/attachment.bin


More information about the svlug mailing list