Relative Content

Tag Archive for filegounixio

Inconsistent behaviour of the `O_NONBLOCK` flag

I am opening the /dev/ptmx file on MacOS 14.2.1. When I open this file,it by default opens in non-blocking mode, I am not sure why because I do not specify O_NONBLOCK flag while opening it. When I try to read from /dev/ptmx I get an EAGAIN error. I even invoke the Fd() method on this file to get the file descriptor, the source code of Fd() puts the file on blocking mode, but in spite of that I get the EAGAIN error. I have found two fixes but I am unable to understand why these fixes work.