Section: Linux Programmer's Manual (3)
Return to Main Contents
dirfd - get directory stream file descriptor
int dirfd(DIR *dirp);
Feature Test Macro Requirements for glibc (see
_BSD_SOURCE || _SVID_SOURCE
|| /* Since glibc 2.10: */
(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
returns the file descriptor associated with the directory stream
This descriptor is the one used internally by the directory stream.
As a result, it is useful only for functions which do not depend on
or alter the file position, such as
It will be automatically closed when
On success, a nonnegative file descriptor is returned.
On error, -1 is returned, and
is set to indicate the cause of the error.
POSIX.1-2008 specifies two errors,
neither of which is returned by the current
does not refer to a valid directory stream.
The implementation does not support the association of a file
descriptor with a directory.
Multithreading (see pthreads(7))
function is thread-safe.
This function was a BSD extension, present in 4.3BSD-Reno, not in 4.2BSD.
The prototype for
is available only if
This page is part of release 3.54 of the Linux
A description of the project,
and information about reporting bugs,
can be found at
- RETURN VALUE
- Multithreading (see pthreads(7))
- CONFORMING TO
- SEE ALSO
This document was created by
using the manual pages.
Time: 13:12:40 GMT, January 16, 2018