CINXE.COM
fileno
<html> <head> <title>fileno</title> <META NAME="KEYWORDS" CONTENT="fileno"> </head> <body BGCOLOR="#ffffff" LINK="#0000ff" VLINK="#0000ff" ALINK="#0000ff" TEXT="#000000"> <center> <h1><b>fileno</b></h1></center> <PRE> <STRONG><A HREF="/man3/FERROR">FERROR(3)</A></STRONG> Linux Programmer's Manual <STRONG><A HREF="/man3/FERROR">FERROR(3)</A></STRONG> NAME clearerr, feof, ferror, fileno - check and reset stream status SYNOPSIS #include <stdio.h> void clearerr(FILE *stream); int feof(FILE *stream); int ferror(FILE *stream); int fileno(FILE *stream); Feature Test Macro Requirements for glibc (see <STRONG><A HREF="/man7/feature_test_macros">feature_test_macros(7)</A></STRONG>): fileno(): _POSIX_C_SOURCE DESCRIPTION The function clearerr() clears the end-of-file and error indicators for the stream pointed to by stream. The function feof() tests the end-of-file indicator for the stream pointed to by stream, returning nonzero if it is set. The end-of-file indicator can be cleared only by the function clearerr(). The function ferror() tests the error indicator for the stream pointed to by stream, returning nonzero if it is set. The error indicator can be reset only by the clearerr() function. The function fileno() examines the argument stream and returns the in- teger file descriptor used to implement this stream. The file descrip- tor is still owned by stream and will be closed when <STRONG><A HREF="/man3/fclose">fclose(3)</A></STRONG> is called. Duplicate the file descriptor with <STRONG><A HREF="/man2/dup">dup(2)</A></STRONG> before passing it to code that might close it. For nonlocking counterparts, see <STRONG><A HREF="/man3/unlocked_stdio">unlocked_stdio(3)</A></STRONG>. ERRORS These functions should not fail and do not set the external variable errno. (However, in case fileno() detects that its argument is not a valid stream, it must return -1 and set errno to EBADF.) ATTRIBUTES For an explanation of the terms used in this section, see at- <STRONG><A HREF="/man7/tributes">tributes(7)</A></STRONG>. +--------------------+---------------+---------+ |Interface | Attribute | Value | +--------------------+---------------+---------+ |clearerr(), feof(), | Thread safety | MT-Safe | |ferror(), fileno() | | | +--------------------+---------------+---------+ CONFORMING TO The functions clearerr(), feof(), and ferror() conform to C89, C99, POSIX.1-2001, and POSIX.1-2008. The function fileno() conforms to POSIX.1-2001 and POSIX.1-2008. SEE ALSO <STRONG><A HREF="/man2/open">open(2)</A></STRONG>, <STRONG><A HREF="/man3/fdopen">fdopen(3)</A></STRONG>, <STRONG><A HREF="/man3/stdio">stdio(3)</A></STRONG>, <STRONG><A HREF="/man3/unlocked_stdio">unlocked_stdio(3)</A></STRONG> COLOPHON This page is part of release 5.05 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/. 2019-03-06 <STRONG><A HREF="/man3/FERROR">FERROR(3)</A></STRONG></PRE> <center> <h6>Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2025 <a href="http://www.he.net">Hurricane Electric</a>. All Rights Reserved.</h6></center> </body> </html>