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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux