dirfd()
Extract the file descriptor for a DIR stream
Synopsis:
#include <dirent.h>
int dirfd( DIR *dirp );
Arguments:
- dirp
- The DIR stream (directory) to extract the file descriptor from.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
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.
Returns:
A file descriptor for the stream, or -1 if an error occurred (errno is set).
Errors:
- EINVAL
- The dirp argument doesn't refer to a valid DIR stream.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |