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 .\" SPDX-License-Identifier: BSD-4-Clause-UC
10 .\" @(#)fclose.3 6.7 (Berkeley) 6/29/91
12 .\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
14 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
16 .TH FCLOSE 3 2021-03-22 "Linux man-pages (unreleased)"
18 fclose \- close a stream
21 .RI ( libc ", " \-lc )
26 .BI "int fclose(FILE *" stream );
31 function flushes the stream pointed to by
33 (writing any buffered output data using
35 and closes the underlying file descriptor.
37 Upon successful completion, 0 is returned.
42 is set to indicate the error.
43 In either case, any further access
44 (including another call to
46 to the stream results in undefined behavior.
50 The file descriptor underlying
53 .\" This error cannot occur unless you are mixing ANSI C stdio operations and
54 .\" low-level file operations on the same stream. If you do get this error,
55 .\" you must have closed the stream's low-level file descriptor using
56 .\" something like close(fileno(stream)).
60 function may also fail and set
62 for any of the errors specified for the routines
68 For an explanation of the terms used in this section, see
76 Interface Attribute Value
79 T} Thread safety MT-Safe
85 POSIX.1-2001, POSIX.1-2008, C89, C99.
89 flushes only the user-space buffers provided by the
91 To ensure that the data is physically stored
92 on disk the kernel buffers must be flushed too, for example, with