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 .\" @(#)fflush.3 5.4 (Berkeley) 6/29/91
13 .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
15 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
16 .\" Modified 2001-10-16 by John Levon <moz@compsoc.man.ac.uk>
18 .TH fflush 3 (date) "Linux man-pages (unreleased)"
20 fflush \- flush a stream
23 .RI ( libc ", " \-lc )
28 .BI "int fflush(FILE *_Nullable " stream );
33 forces a write of all user-space buffered data for the given output or update
35 via the stream's underlying write function.
37 For input streams associated with seekable files
38 (e.g., disk files, but not pipes or terminals),
40 discards any buffered data that has been fetched from the underlying file,
41 but has not been consumed by the application.
43 The open status of the stream is unaffected.
52 .\" mtk: POSIX specifies that only output streams are flushed for this case.
53 .\" Also verified for glibc by experiment.
55 For a nonlocking counterpart, see
56 .BR unlocked_stdio (3).
58 Upon successful completion 0 is returned.
63 is set to indicate the error.
68 is not an open stream, or is not open for writing.
74 for any of the errors specified for
77 For an explanation of the terms used in this section, see
83 Interface Attribute Value
88 T} Thread safety MT-Safe
94 C89, POSIX.1-2001, POSIX.1-2008.
96 POSIX.1-2001 did not specify the behavior for flushing of input streams,
97 but the behavior is specified in POSIX.1-2008.
101 flushes only the user-space buffers provided by the C library.
102 To ensure that the data is physically stored on disk
103 the kernel buffers must be flushed too, for example, with
116 .BR unlocked_stdio (3)