1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
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.
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
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.
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
38 .\" @(#)fclose.3 6.7 (Berkeley) 6/29/91
40 .\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
42 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
44 .TH FCLOSE 3 2021-03-22 "GNU" "Linux Programmer's Manual"
46 fclose \- close a stream
51 .BI "int fclose(FILE *" stream );
56 function flushes the stream pointed to by
58 (writing any buffered output data using
60 and closes the underlying file descriptor.
62 Upon successful completion, 0 is returned.
67 is set to indicate the error.
68 In either case, any further access
69 (including another call to
71 to the stream results in undefined behavior.
75 The file descriptor underlying
78 .\" This error cannot occur unless you are mixing ANSI C stdio operations and
79 .\" low-level file operations on the same stream. If you do get this error,
80 .\" you must have closed the stream's low-level file descriptor using
81 .\" something like close(fileno(stream)).
85 function may also fail and set
87 for any of the errors specified for the routines
93 For an explanation of the terms used in this section, see
101 Interface Attribute Value
104 T} Thread safety MT-Safe
110 POSIX.1-2001, POSIX.1-2008, C89, C99.
114 flushes only the user-space buffers provided by the
116 To ensure that the data is physically stored
117 on disk the kernel buffers must be flushed too, for example, with