mount_setattr.2: Minor tweaks to Christian's patch
[man-pages.git] / man3 / ferror.3
blobcb63e24fc42dadc59eaf0c495f477925d01768f4
1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" and Copyright (C) 2021 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Chris Torek and the American National Standards Committee X3,
7 .\" on Information Processing Systems.
8 .\"
9 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
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. All advertising materials mentioning features or use of this software
19 .\"    must display the following acknowledgement:
20 .\"     This product includes software developed by the University of
21 .\"     California, Berkeley and its contributors.
22 .\" 4. Neither the name of the University nor the names of its contributors
23 .\"    may be used to endorse or promote products derived from this software
24 .\"    without specific prior written permission.
25 .\"
26 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 .\" SUCH DAMAGE.
37 .\" %%%LICENSE_END
38 .\"
39 .\"     @(#)ferror.3    6.8 (Berkeley) 6/29/91
40 .\"
41 .\"
42 .\" Converted for Linux, Mon Nov 29 14:24:40 1993, faith@cs.unc.edu
43 .\"
44 .TH FERROR 3  2021-03-22 "" "Linux Programmer's Manual"
45 .SH NAME
46 clearerr, feof, ferror \- check and reset stream status
47 .SH SYNOPSIS
48 .nf
49 .B #include <stdio.h>
50 .PP
51 .BI "void clearerr(FILE *" stream );
52 .BI "int feof(FILE *" stream );
53 .BI "int ferror(FILE *" stream );
54 .fi
55 .SH DESCRIPTION
56 The function
57 .BR clearerr ()
58 clears the end-of-file and error indicators for the stream pointed to by
59 .IR stream .
60 .PP
61 The function
62 .BR feof ()
63 tests the end-of-file indicator for the stream pointed to by
64 .IR stream ,
65 returning nonzero if it is set.
66 The end-of-file indicator can be cleared only by the function
67 .BR clearerr ().
68 .PP
69 The function
70 .BR ferror ()
71 tests the error indicator for the stream pointed to by
72 .IR stream ,
73 returning nonzero if it is set.
74 The error indicator can be reset only by the
75 .BR clearerr ()
76 function.
77 .PP
78 For nonlocking counterparts, see
79 .BR unlocked_stdio (3).
80 .SH RETURN VALUE
81 The
82 .BR feof ()
83 function returns nonzero if the end-of-file indicator is set for
84 .IR stream ;
85 otherwise, it returns zero.
86 .PP
87 The
88 .BR ferror ()
89 function returns nonzero if the error indicator is set for
90 .IR stream ;
91 otherwise, it returns zero.
92 .SH ERRORS
93 These functions should not fail and do not set
94 .IR errno .
95 .SH ATTRIBUTES
96 For an explanation of the terms used in this section, see
97 .BR attributes (7).
98 .ad l
99 .nh
101 allbox;
102 lbx lb lb
103 l l l.
104 Interface       Attribute       Value
106 .BR clearerr (),
107 .BR feof (),
108 .BR ferror ()
109 T}      Thread safety   MT-Safe
113 .sp 1
114 .SH CONFORMING TO
115 The functions
116 .BR clearerr (),
117 .BR feof (),
119 .BR ferror ()
120 conform to C89, C99, POSIX.1-2001, and POSIX.1-2008.
121 .SH NOTES
122 POSIX.1-2008 specifies
123 .\"https://www.austingroupbugs.net/view.php?id=401
124 that these functions shall not change the value of
125 .I errno
127 .I stream
128 is valid.
129 .SH SEE ALSO
130 .BR open (2),
131 .BR fdopen (3),
132 .BR fileno (3),
133 .BR stdio (3),
134 .BR unlocked_stdio (3)