Dan Kegel wrote: > As long as we agree that the kernel may provide spurious readiness > notifications on occasion, I agree. Great! We agree! Progress! >>> while (read() == EAGAIN) >>> wait(POLLIN); >>> >> Assuming registration of interest is inside wait(), this has a race. >> If the file becomes readable between the time that read() returns and >> the time that wait() can register interest, the connection will hang. > > > Shouldn't the should be rearmed inside read() when it returns EAGAIN? The key phrase is "assuming registration of interest is inside wait()." The code fragment didn't cover when registration of interest occurs. If registration of interest occurs before the read() or if registration of interest while the fd is ready generates an event, there is no race. If registration of interest occurs after the read() and registration of interest while the fd is ready does not generate an event, there is a race.