Updated: April 19, 2023 |
Extract the file descriptor for a DIR stream
#include <dirent.h> int dirfd( DIR *dirp );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The dirfd() function returns a file descriptor referring to the DIR stream (directory) indicated by the dirp argument. You can use this file descriptor with any of the *at() functions.
If an attempt is made to close the file descriptor or modify the state of the associated description, other than by calling the functions closedir(), readdir(), readdir_r(), rewinddir(), or seekdir(), the behavior is undefined.
Call closedir() to close the DIR stream; this also closes the file descriptor.
A file descriptor for the stream, or -1 if an error occurred (errno is set).
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |