1.\" $NetBSD: ferror.3,v 1.14 2010/05/08 11:35:14 wiz Exp $ 2.\" 3.\" Copyright (c) 1990, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" Chris Torek and the American National Standards Committee X3, 8.\" on Information Processing Systems. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)ferror.3 8.2 (Berkeley) 4/19/94 35.\" 36.Dd May 6, 2010 37.Dt FERROR 3 38.Os 39.Sh NAME 40.Nm clearerr , 41.Nm feof , 42.Nm ferror , 43.Nm fileno 44.Nd check and reset stream status 45.Sh LIBRARY 46.Lb libc 47.Sh SYNOPSIS 48.In stdio.h 49.Ft void 50.Fn clearerr "FILE *stream" 51.Ft int 52.Fn feof "FILE *stream" 53.Ft int 54.Fn ferror "FILE *stream" 55.Ft int 56.Fn fileno "FILE *stream" 57.Sh DESCRIPTION 58The function 59.Fn clearerr 60clears the end-of-file and error indicators for the stream pointed 61to by 62.Fa stream . 63.Pp 64The function 65.Fn feof 66tests the end-of-file indicator for the stream pointed to by 67.Fa stream , 68returning non-zero if it is set. 69The end-of-file indicator can only be cleared by the function 70.Fn clearerr . 71.Pp 72The function 73.Fn ferror 74tests the error indicator for the stream pointed to by 75.Fa stream , 76returning non-zero if it is set. 77The error indicator can only be reset by the 78.Fn clearerr 79function. 80.Pp 81The function 82.Fn fileno 83examines the argument 84.Fa stream 85and returns its integer descriptor. 86.Sh ERRORS 87The functions 88.Fn clearerr , 89.Fn feof , 90and 91.Fn ferror 92should neither fail nor set the external variable 93.Va errno . 94However, the function 95.Fn fileno 96may fail and return \-1 in case the argument 97.Fa stream 98is not associated with a valid file descriptor. 99(In this case the 100.Nx 101implementation does not follow the optional 102.Tn POSIX 103recommendation to set the 104.Va errno 105variable to 106.Er EBADF . ) 107.Sh SEE ALSO 108.Xr open 2 , 109.Xr stdio 3 110.Sh STANDARDS 111The functions 112.Fn clearerr , 113.Fn feof , 114and 115.Fn ferror 116conform to 117.St -ansiC . 118The function 119.Fn fileno 120conforms to 121.St -p1003.1-90 . 122