...
It is necessary to call the fstat() function on an already opened file, rather than calling stat() on a file name followed by open() to ensure the file for which the information is being collected is the same file that is opened. See FIO01-A. Be careful using functions that use file names for identification for more information on avoiding race conditions resulting from the use of file names for identification.
It may also be necessary to call {{Wiki Markup open()}} with {{O_NONBLOCK}} as per \[[FIO32-C. Do not perform operations on devices that are only appropriate for files]\] to ensure that the program does not hang when trying to open special files.
This example is a valid exception to the recommendation: FIO16-A. Avoid reopening a file stream.
...