OSDN Git Service

8cac3bf16788a30b735d8686814801a92c38b41b
[linuxjm/LDP_man-pages.git] / original / man3 / ferror.3
1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" 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 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\"    must display the following acknowledgement:
19 .\"     This product includes software developed by the University of
20 .\"     California, Berkeley and its contributors.
21 .\" 4. Neither the name of the University nor the names of its contributors
22 .\"    may be used to endorse or promote products derived from this software
23 .\"    without specific prior written permission.
24 .\"
25 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" SUCH DAMAGE.
36 .\" %%%LICENSE_END
37 .\"
38 .\"     @(#)ferror.3    6.8 (Berkeley) 6/29/91
39 .\"
40 .\"
41 .\" Converted for Linux, Mon Nov 29 14:24:40 1993, faith@cs.unc.edu
42 .\" Added remark on EBADF for fileno, aeb, 2001-03-22
43 .\"
44 .TH FERROR 3  2014-01-15 "" "Linux Programmer's Manual"
45 .SH NAME
46 clearerr, feof, ferror, fileno \- check and reset stream status
47 .SH SYNOPSIS
48 .B #include <stdio.h>
49 .sp
50 .BI "void clearerr(FILE *" stream );
51
52 .BI "int feof(FILE *" stream );
53
54 .BI "int ferror(FILE *" stream );
55
56 .BI "int fileno(FILE *" stream );
57 .sp
58 .in -4n
59 Feature Test Macro Requirements for glibc (see
60 .BR feature_test_macros (7)):
61 .in
62 .sp
63 .BR fileno ():
64 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
65 .SH DESCRIPTION
66 The function
67 .BR clearerr ()
68 clears the end-of-file and error indicators for the stream pointed to by
69 .IR stream .
70 .PP
71 The function
72 .BR feof ()
73 tests the end-of-file indicator for the stream pointed to by
74 .IR stream ,
75 returning nonzero if it is set.
76 The end-of-file indicator can be cleared only by the function
77 .BR clearerr ().
78 .PP
79 The function
80 .BR ferror ()
81 tests the error indicator for the stream pointed to by
82 .IR stream ,
83 returning nonzero if it is set.
84 The error indicator can be reset only by the
85 .BR clearerr ()
86 function.
87 .PP
88 The function
89 .BR fileno ()
90 examines the argument
91 .I stream
92 and returns its integer descriptor.
93 .PP
94 For nonlocking counterparts, see
95 .BR unlocked_stdio (3).
96 .SH ERRORS
97 These functions should not fail and do not set the external variable
98 .IR errno .
99 (However, in case
100 .BR fileno ()
101 detects that its argument is not a valid stream, it must
102 return \-1 and set
103 .I errno
104 to
105 .BR EBADF .)
106 .SH ATTRIBUTES
107 .SS Multithreading (see pthreads(7))
108 The
109 .BR clearerr (),
110 .BR feof (),
111 .BR ferror (),
112 and
113 .BR fileno ()
114 functions are thread-safe.
115 .SH CONFORMING TO
116 The functions
117 .BR clearerr (),
118 .BR feof (),
119 and
120 .BR ferror ()
121 conform to C89, C99, POSIX.1-2001, and POSIX.1-2008.
122
123 The function
124 .BR fileno ()
125 conforms to POSIX.1-2001 and POSIX.1-2008.
126 .SH SEE ALSO
127 .BR open (2),
128 .BR fdopen (3),
129 .BR stdio (3),
130 .BR unlocked_stdio (3)
131 .SH COLOPHON
132 This page is part of release 3.67 of the Linux
133 .I man-pages
134 project.
135 A description of the project,
136 information about reporting bugs,
137 and the latest version of this page,
138 can be found at
139 \%http://www.kernel.org/doc/man\-pages/.