D. J. Bernstein

Asynchronous access to disk files

UNIX kernel designers should provide an O_HONESTBLOCKING option to open() that has the same blocking effects as opening a pipe to a separate program that accesses the file.

Specifically, here are the effects on reading:

Similarly, here are the effects on writing: For extra credit, also add an O_OPENLATER option meaning that open() always succeeds immediately (if descriptor space is available), with errors such as EACCES reported on the first read() or write().

Similar effects to O_HONESTBLOCKING can be achieved on some kernels with the aio_read() and aio_write() functions. The difference is that O_HONESTBLOCKING works with a traditional select()/poll() loop, traditional non-blocking read(), etc.

Perhaps O_HONESTBLOCKING should be the default in UNIX. Why would a program bother using select(), poll(), non-blocking read(), etc. if it is unprepared for the possibility of descriptors not being ready?