...
When opening a FIFO with
O_RDONLYorO_WRONLYset: IfO_NONBLOCKis set:
An open() for reading only will return without delay. An open() for writing only will return an error if no process currently has the file open for reading.
IfO_NONBLOCKis clear:
An open() for reading only will block the calling thread until a thread opens the file for writing. An open() for writing only will block the calling thread until a thread opens the file for reading.When opening a block special or character special file that supports non-blocking opens:
IfO_NONBLOCKis set:
The open() function will return without blocking for the device to be ready or available. Subsequent behaviour of the device is device-specific.
IfO_NONBLOCKis clear:
The open() function will block the calling thread until the device is ready or available before returning.Otherwise, the behaviour of
O_NONBLOCKis unspecified.
| Wiki Markup |
|---|
Once the file is open, programmers can use the POSIX {{lstat()}}/{{fstat() |
}} functions to obtain information about a named file, and the {{S_ISREG()}} macro to determine if the file is a regular file. (see \[[FIO05-A. Identify files using multiple file attributes]\]) |
Since the behavior of O_NONBLOCK on subsequent calls to read() or write() is unspecified, it is advisable to disable the flag once we are sure the file in question is not a special device.
...
| Wiki Markup |
|---|
\[[Garfinkel 96|AA. C References#Garfinkel 96]\] Section 5.6, "Device Files" \[[Howard 02|AA. C References#Howard 02]\] Chapter 11, "Canonical Representation Issues" \[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\] Section |
Related Rules and Recommendations
...
...
FIO31-C. Do not simultaneously open the same file multiple times 09. Input Output (FIO) FIO33-C. Detect and handle input output errors resulting in undefined behavior