1FFLUSH(3) Linux Programmer's Manual FFLUSH(3)
2
3
4
6 fflush - flush a stream
7
9 #include <stdio.h>
10
11 int fflush(FILE *stream);
12
14 For output streams, fflush() forces a write of all user-space buffered
15 data for the given output or update stream via the stream's underlying
16 write function.
17
18 For input streams associated with seekable files (e.g., disk files, but
19 not pipes or terminals), fflush() discards any buffered data that has
20 been fetched from the underlying file, but has not been consumed by the
21 application.
22
23 The open status of the stream is unaffected.
24
25 If the stream argument is NULL, fflush() flushes all open output
26 streams.
27
28 For a nonlocking counterpart, see unlocked_stdio(3).
29
31 Upon successful completion 0 is returned. Otherwise, EOF is returned
32 and errno is set to indicate the error.
33
35 EBADF stream is not an open stream, or is not open for writing.
36
37 The function fflush() may also fail and set errno for any of the errors
38 specified for write(2).
39
41 For an explanation of the terms used in this section, see at‐
42 tributes(7).
43
44 ┌────────────────────────────────────────────┬───────────────┬─────────┐
45 │Interface │ Attribute │ Value │
46 ├────────────────────────────────────────────┼───────────────┼─────────┤
47 │fflush() │ Thread safety │ MT-Safe │
48 └────────────────────────────────────────────┴───────────────┴─────────┘
49
51 C89, C99, POSIX.1-2001, POSIX.1-2008.
52
53 POSIX.1-2001 did not specify the behavior for flushing of input
54 streams, but the behavior is specified in POSIX.1-2008.
55
57 Note that fflush() flushes only the user-space buffers provided by the
58 C library. To ensure that the data is physically stored on disk the
59 kernel buffers must be flushed too, for example, with sync(2) or
60 fsync(2).
61
63 fsync(2), sync(2), write(2), fclose(3), fileno(3), fopen(3), fpurge(3),
64 setbuf(3), unlocked_stdio(3)
65
67 This page is part of release 5.13 of the Linux man-pages project. A
68 description of the project, information about reporting bugs, and the
69 latest version of this page, can be found at
70 https://www.kernel.org/doc/man-pages/.
71
72
73
74GNU 2021-08-27 FFLUSH(3)