Re: poll() returns even if there is data.

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

 



Mansuri, Wasim (NSN - IN/Bangalore) wrote:

> My question here is, 
> 	Am I using poll() properly?
> 	can we use poll to read the files like I am reading?
> 	If we can not use poll than is there any other way using which I can get to know if there is some data in the file after I did last read()?

I'm not sure if poll can be used in this way.
poll() is answering your question about "can I read?" and saying yes, which
apparently means "you have an end-of-file to read".
poll() is used to avoid blocking on sockets and pipes, and, guess what,
your read() is not blocking, so poll() was right to suggest you to read. :-)

You can use the offset returned by lseek() to make a comparison
with your last read offset, but it will be a busy loop (hopefully
with some delay) and not a "wake me up" method. Not so different than
just looping on read(), actually. :-/

Why don't you try checking how "tail -f" is implemented? There is
an "interval" parameter, so I'm afraid it is looping....
A simple strace could be enough, probably easier than reading the source.

-- 
   Roberto Ragusa    mail at robertoragusa.it
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux