Recently, I have had many opportunities to check the Linux API for various reasons.
open() read()
There is a fatal mistake in these two (or rather read ()).
open () is certainly correct. Block if O_NONBLOCK is not specified. But read () does not block. It has nothing to do with the open mode of fd. Once read () is successful, continue reading non-blocking (experiment with FIFO).
It's a big mistake to think that read () will block. Check it out for yourself. I dare not issue the code.