2 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
3 .\" All rights reserved.
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.
9 .\" SPDX-License-Identifier: BSD-4-Clause-UC
11 .\" @(#)fclose.3 6.7 (Berkeley) 6/29/91
13 .\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
15 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
17 .TH fclose 3 (date) "Linux man-pages (unreleased)"
19 fclose \- close a stream
22 .RI ( libc ", " \-lc )
27 .BI "int fclose(FILE *" stream );
32 function flushes the stream pointed to by
34 (writing any buffered output data using
36 and closes the underlying file descriptor.
38 Upon successful completion, 0 is returned.
43 is set to indicate the error.
44 In either case, any further access
45 (including another call to
47 to the stream results in undefined behavior.
51 The file descriptor underlying
54 .\" This error cannot occur unless you are mixing ANSI C stdio operations and
55 .\" low-level file operations on the same stream. If you do get this error,
56 .\" you must have closed the stream's low-level file descriptor using
57 .\" something like close(fileno(stream)).
61 function may also fail and set
63 for any of the errors specified for the routines
69 For an explanation of the terms used in this section, see
75 Interface Attribute Value
80 T} Thread safety MT-Safe
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