NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | STANDARDS | HISTORY | SEE ALSO | COLOPHON |
|
|
fileno(3) Library Functions Manual fileno(3)
fileno - obtain file descriptor of a stdio stream
Standard C library (libc, -lc)
#include <stdio.h> int fileno(FILE *stream); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): fileno(): _POSIX_C_SOURCE
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 the error.
EBADF stream is not associated with a file.
For an explanation of the terms used in this section, see attributes(7). ┌─────────────────────────────────────┬───────────────┬─────────┐ │ Interface │ Attribute │ Value │ ├─────────────────────────────────────┼───────────────┼─────────┤ │ fileno() │ Thread safety │ MT-Safe │ └─────────────────────────────────────┴───────────────┴─────────┘
POSIX.1-2008.
POSIX.1-2001.
open(2), fdopen(3), stdio(3), unlocked_stdio(3)
This page is part of the man-pages (Linux kernel and C library
user-space interface documentation) project. Information about
the project can be found at
⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report
for this manual page, see
⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
This page was obtained from the tarball man-pages-6.9.1.tar.gz
fetched from
⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
2024-06-26. If you discover any rendering problems in this HTML
version of the page, or you believe there is a better or more up-
to-date source for the page, or you have corrections or
improvements to the information in this COLOPHON (which is not
part of the original manual page), send a mail to
man-pages@man7.org
Linux man-pages 6.9.1 2024-05-02 fileno(3)
Pages that refer to this page: fsync(2), fclose(3), ferror(3), fflush(3), fmemopen(3), fopen(3), open_memstream(3), pcap_file(3pcap), stdio(3)