fileno - obtain file descriptor of a stdio stream
int fileno(FILE *stream);
The function fileno() examines the argument stream and returns the
integer file descriptor used to implement this stream. The file descriptor is
still owned by stream and will be closed when fclose(3) is
called. Duplicate the file descriptor with dup(2) before passing it to
code that might close it.
For the nonlocking counterpart, see unlocked_stdio(3).
On success, fileno() returns the file descriptor associated with
stream. On failure, -1 is returned and errno is set to indicate
For an explanation of the terms used in this section, see attributes(7).
- stream is not associated with a file.
The function fileno() conforms to POSIX.1-2001 and POSIX.1-2008.
This page is part of release 5.12 of the Linux man-pages project. A
description of the project, information about reporting bugs, and the latest
version of this page, can be found at https://www.kernel.org/doc/man-pages/.