@alexcrichton This isn't about assuming it will go right. This is about the documented errors that `fcntl()` can return. According to POSIX the only valid error it can return here matches an error that `read` and `write` would return (for the same reason). And Linux documents a second error that I don't believe we can ever hit.

The problem with trying to handle errno correctly is that we can't simply save errno and restore it to what it was before the fcntl. And trying to change things such that `blocking()` returns the `IoResult` directly is awkward. The one thing I could do is re-issue the call to `read`/`write`, and I'm willing to do that if it makes you happy, but I just don't think it's necessary.

> In the spirit of defensive programming, please remove the loop.

No. That's absolutely incorrect. The loop makes progress on every single pass through it (either by succeeding, or by removing the `O_NONBLOCK` flag). Removing the loop makes this code *wrong*. It in fact exists because of the spirit of defensive programming. It's defending against a rare race condition where some other thread/process just happens to flip `O_NONBLOCK` back on at the wrong time.

Removing the loop here would be like removing the loop in an atomic.fetch_and_add() implementation because you don't want that to spin forever.