Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Specifying the O_NONBLOCK flag when opening a file serves two purposes:
If the file can’t be opened immediately, then open() returns an error instead of blocking. One case where open() can block is with FIFOs (Section 44.7).
After a successful open(), subsequent I/O operations are also nonblocking. If an I/O system call can’t complete immediately, then either a partial data transfer is performed or the system call fails with one of the errors EAGAIN or EWOULDBLOCK. Which error is returned depends on the system call. On Linux, as on many UNIX implementations, these two error constants are synonymous.