Nonblocking I/O and POLL_BUG
harik at chaos.ao.net
Mon Oct 25 19:18:55 UTC 1999
Per Hedeland writes:
> I'm not quite sure I follow you here, but: If select() (or poll())
> returns saying that a descriptor is ready for reading, and you get
> EAGAIN when first trying to read it, that is most definitely a bug.
> Likewise if that read returns 0 without a "real" EOF condition
> existing. Plus of course per above one has to wonder why one on Solaris
> would *ever* get EAGAIN on read() when using O_NDELAY to set
> non-blocking mode...
> I think that if you don't get spurious EAGAINs on Solaris, you won't get
> them anywhere:-) - it seems that OS may occasionally return it on just
> about *any* system call, non-blocking mode or not. It has probably
> improved in recent times though, the question is how much you need to
> worry about the code being run on older versions.
Actually, I may be wrong but it's possible to be interrupted by a signal
even on a "fast" read, no? I've coded my select/poll loops in such a way as
to treat -EAGAIN as a non-error, but lately I've put a spin counter in.
(detects both OS errors and my own braindead screwups... like reading the
wrong fd_set after select.)
More information about the inn-workers