158f0484fSRodney W. Grimes.\" Copyright (c) 1990, 1991, 1993 258f0484fSRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 358f0484fSRodney W. Grimes.\" 458f0484fSRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 558f0484fSRodney W. Grimes.\" Chris Torek and the American National Standards Committee X3, 658f0484fSRodney W. Grimes.\" on Information Processing Systems. 758f0484fSRodney W. Grimes.\" 858f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 958f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions 1058f0484fSRodney W. Grimes.\" are met: 1158f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 1258f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 1358f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 1458f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 1558f0484fSRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 16fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 1758f0484fSRodney W. Grimes.\" may be used to endorse or promote products derived from this software 1858f0484fSRodney W. Grimes.\" without specific prior written permission. 1958f0484fSRodney W. Grimes.\" 2058f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2158f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2258f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2358f0484fSRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2458f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2558f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2658f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2758f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2858f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2958f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3058f0484fSRodney W. Grimes.\" SUCH DAMAGE. 3158f0484fSRodney W. Grimes.\" 324b7f35dbSGordon Bergling.Dd April 2, 2022 3358f0484fSRodney W. Grimes.Dt FERROR 3 3458f0484fSRodney W. Grimes.Os 3558f0484fSRodney W. Grimes.Sh NAME 3658f0484fSRodney W. Grimes.Nm clearerr , 374549f620STim J. Robbins.Nm clearerr_unlocked , 3858f0484fSRodney W. Grimes.Nm feof , 394549f620STim J. Robbins.Nm feof_unlocked , 4058f0484fSRodney W. Grimes.Nm ferror , 414549f620STim J. Robbins.Nm ferror_unlocked , 424549f620STim J. Robbins.Nm fileno , 434549f620STim J. Robbins.Nm fileno_unlocked 4458f0484fSRodney W. Grimes.Nd check and reset stream status 4525bb73e0SAlexey Zelkin.Sh LIBRARY 4625bb73e0SAlexey Zelkin.Lb libc 4758f0484fSRodney W. Grimes.Sh SYNOPSIS 4832eef9aeSRuslan Ermilov.In stdio.h 4958f0484fSRodney W. Grimes.Ft void 5058f0484fSRodney W. Grimes.Fn clearerr "FILE *stream" 514549f620STim J. Robbins.Ft void 524549f620STim J. Robbins.Fn clearerr_unlocked "FILE *stream" 5358f0484fSRodney W. Grimes.Ft int 5458f0484fSRodney W. Grimes.Fn feof "FILE *stream" 5558f0484fSRodney W. Grimes.Ft int 564549f620STim J. Robbins.Fn feof_unlocked "FILE *stream" 574549f620STim J. Robbins.Ft int 5858f0484fSRodney W. Grimes.Fn ferror "FILE *stream" 5958f0484fSRodney W. Grimes.Ft int 604549f620STim J. Robbins.Fn ferror_unlocked "FILE *stream" 614549f620STim J. Robbins.Ft int 6258f0484fSRodney W. Grimes.Fn fileno "FILE *stream" 634549f620STim J. Robbins.Ft int 644549f620STim J. Robbins.Fn fileno_unlocked "FILE *stream" 6558f0484fSRodney W. Grimes.Sh DESCRIPTION 6658f0484fSRodney W. GrimesThe function 6758f0484fSRodney W. Grimes.Fn clearerr 6858f0484fSRodney W. Grimesclears the end-of-file and error indicators for the stream pointed 6958f0484fSRodney W. Grimesto by 7058f0484fSRodney W. Grimes.Fa stream . 7158f0484fSRodney W. Grimes.Pp 7258f0484fSRodney W. GrimesThe function 7358f0484fSRodney W. Grimes.Fn feof 7458f0484fSRodney W. Grimestests the end-of-file indicator for the stream pointed to by 7558f0484fSRodney W. Grimes.Fa stream , 7658f0484fSRodney W. Grimesreturning non-zero if it is set. 77f53807d2STom RhodesThe end-of-file indicator may be cleared by explicitly calling 78f53807d2STom Rhodes.Fn clearerr , 79f53807d2STom Rhodesor as a side-effect of other operations, e.g.\& 80f53807d2STom Rhodes.Fn fseek . 8158f0484fSRodney W. Grimes.Pp 8258f0484fSRodney W. GrimesThe function 8358f0484fSRodney W. Grimes.Fn ferror 8458f0484fSRodney W. Grimestests the error indicator for the stream pointed to by 8558f0484fSRodney W. Grimes.Fa stream , 8658f0484fSRodney W. Grimesreturning non-zero if it is set. 8758f0484fSRodney W. Grimes.Pp 8858f0484fSRodney W. GrimesThe function 8958f0484fSRodney W. Grimes.Fn fileno 9058f0484fSRodney W. Grimesexamines the argument 9158f0484fSRodney W. Grimes.Fa stream 9258f0484fSRodney W. Grimesand returns its integer descriptor. 934549f620STim J. Robbins.Pp 944549f620STim J. RobbinsThe 954549f620STim J. Robbins.Fn clearerr_unlocked , 964549f620STim J. Robbins.Fn feof_unlocked , 974549f620STim J. Robbins.Fn ferror_unlocked , 984549f620STim J. Robbinsand 994549f620STim J. Robbins.Fn fileno_unlocked 1004549f620STim J. Robbinsfunctions are equivalent to 1014549f620STim J. Robbins.Fn clearerr , 1024549f620STim J. Robbins.Fn feof , 1034549f620STim J. Robbins.Fn ferror , 1044549f620STim J. Robbinsand 1054549f620STim J. Robbins.Fn fileno 1064549f620STim J. Robbinsrespectively, except that the caller is responsible for locking the stream 1074549f620STim J. Robbinswith 108522ccf3fSRuslan Ermilov.Xr flockfile 3 1094549f620STim J. Robbinsbefore calling them. 1104549f620STim J. RobbinsThese functions may be used to avoid the overhead of locking the stream 1114549f620STim J. Robbinsand to prevent races when multiple threads are operating on the same stream. 11258f0484fSRodney W. Grimes.Sh ERRORS 113*7cd756ffSKonstantin BelousovThese functions, except 114*7cd756ffSKonstantin Belousov.Fn fileno , 115*7cd756ffSKonstantin Belousovshould not fail and do not set the external variable 11658f0484fSRodney W. Grimes.Va errno . 117*7cd756ffSKonstantin Belousov.Pp 118*7cd756ffSKonstantin BelousovOn error, 119*7cd756ffSKonstantin Belousov.Fn fileno 120*7cd756ffSKonstantin Belousovreturns \-1 and sets 121*7cd756ffSKonstantin Belousov.Va errno 122*7cd756ffSKonstantin Belousovto one of the following values: 123*7cd756ffSKonstantin Belousov.Bl -tag -width Er 124*7cd756ffSKonstantin Belousov.It Bq Er EBADF 125*7cd756ffSKonstantin BelousovThe stream is not associated with a file. 126*7cd756ffSKonstantin Belousov.It Bq Er EBADF 127*7cd756ffSKonstantin BelousovThe file descriptor underlying stream is not a valid file descriptor. 128*7cd756ffSKonstantin Belousov.Pp 129*7cd756ffSKonstantin BelousovNote that detection of this condition is not reliable, the error might 130*7cd756ffSKonstantin Belousovbe not reported. 131*7cd756ffSKonstantin Belousov.El 13258f0484fSRodney W. Grimes.Sh SEE ALSO 13358f0484fSRodney W. Grimes.Xr open 2 , 134ac8b27d2SMurray Stokely.Xr fdopen 3 , 1354549f620STim J. Robbins.Xr flockfile 3 , 13658f0484fSRodney W. Grimes.Xr stdio 3 13758f0484fSRodney W. Grimes.Sh STANDARDS 13858f0484fSRodney W. GrimesThe functions 13958f0484fSRodney W. Grimes.Fn clearerr , 14058f0484fSRodney W. Grimes.Fn feof , 14158f0484fSRodney W. Grimesand 14258f0484fSRodney W. Grimes.Fn ferror 14358f0484fSRodney W. Grimesconform to 144588a200cSRuslan Ermilov.St -isoC . 1454b7f35dbSGordon Bergling.Sh HISTORY 1464b7f35dbSGordon BerglingThe functions 1474b7f35dbSGordon Bergling.Fn clearerr , 1484b7f35dbSGordon Bergling.Fn feof , 1494b7f35dbSGordon Bergling.Fn ferror , 1504b7f35dbSGordon Berglingand 1514b7f35dbSGordon Bergling.Fn fileno 1524b7f35dbSGordon Berglingfirst appeared in 1534b7f35dbSGordon Bergling.At v7 . 154