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 .\" @(#)fflush.3 5.4 (Berkeley) 6/29/91
12 .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
14 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
15 .\" Modified 2001-10-16 by John Levon <moz@compsoc.man.ac.uk>
17 .TH FFLUSH 3 2021-08-27 "Linux man-pages (unreleased)"
19 fflush \- flush a stream
22 .RI ( libc ", " \-lc )
27 .BI "int fflush(FILE *" stream );
32 forces a write of all user-space buffered data for the given output or update
34 via the stream's underlying write function.
36 For input streams associated with seekable files
37 (e.g., disk files, but not pipes or terminals),
39 discards any buffered data that has been fetched from the underlying file,
40 but has not been consumed by the application.
42 The open status of the stream is unaffected.
51 .\" mtk: POSIX specifies that only output streams are flushed for this case.
52 .\" Also verified for glibc by experiment.
54 For a nonlocking counterpart, see
55 .BR unlocked_stdio (3).
57 Upon successful completion 0 is returned.
62 is set to indicate the error.
67 is not an open stream, or is not open for writing.
73 for any of the errors specified for
76 For an explanation of the terms used in this section, see
84 Interface Attribute Value
87 T} Thread safety MT-Safe
93 C89, C99, POSIX.1-2001, POSIX.1-2008.
95 POSIX.1-2001 did not specify the behavior for flushing of input streams,
96 but the behavior is specified in POSIX.1-2008.
100 flushes only the user-space buffers provided by the C library.
101 To ensure that the data is physically stored on disk
102 the kernel buffers must be flushed too, for example, with
115 .BR unlocked_stdio (3)