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