1FFLUSH(3)                  Linux Programmer's Manual                 FFLUSH(3)
2
3
4

NAME

6       fflush - flush a stream
7

SYNOPSIS

9       #include <stdio.h>
10
11       int fflush(FILE *stream);
12

DESCRIPTION

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

RETURN VALUE

31       Upon  successful  completion 0 is returned.  Otherwise, EOF is returned
32       and errno is set to indicate the error.
33

ERRORS

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

ATTRIBUTES

41       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
42       tributes(7).
43
44       ┌──────────┬───────────────┬─────────┐
45Interface Attribute     Value   
46       ├──────────┼───────────────┼─────────┤
47fflush()  │ Thread safety │ MT-Safe │
48       └──────────┴───────────────┴─────────┘

CONFORMING TO

50       C89, C99, POSIX.1-2001, POSIX.1-2008.
51
52       POSIX.1-2001 did  not  specify  the  behavior  for  flushing  of  input
53       streams, but the behavior is specified in POSIX.1-2008.
54

NOTES

56       Note  that fflush() flushes only the user-space buffers provided by the
57       C library.  To ensure that the data is physically stored  on  disk  the
58       kernel  buffers  must  be  flushed  too,  for  example, with sync(2) or
59       fsync(2).
60

SEE ALSO

62       fsync(2), sync(2), write(2), fclose(3), fileno(3), fopen(3), setbuf(3),
63       unlocked_stdio(3)
64

COLOPHON

66       This  page  is  part of release 5.10 of the Linux man-pages project.  A
67       description of the project, information about reporting bugs,  and  the
68       latest     version     of     this    page,    can    be    found    at
69       https://www.kernel.org/doc/man-pages/.
70
71
72
73GNU                               2017-09-15                         FFLUSH(3)
Impressum