1fflush(3)                  Library Functions Manual                  fflush(3)
2
3
4

NAME

6       fflush - flush a stream
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <stdio.h>
13
14       int fflush(FILE *_Nullable stream);
15

DESCRIPTION

17       For  output streams, fflush() forces a write of all user-space buffered
18       data for the given output or update stream via the stream's  underlying
19       write function.
20
21       For input streams associated with seekable files (e.g., disk files, but
22       not pipes or terminals), fflush() discards any buffered data  that  has
23       been fetched from the underlying file, but has not been consumed by the
24       application.
25
26       The open status of the stream is unaffected.
27
28       If the stream argument  is  NULL,  fflush()  flushes  all  open  output
29       streams.
30
31       For a nonlocking counterpart, see unlocked_stdio(3).
32

RETURN VALUE

34       Upon  successful  completion 0 is returned.  Otherwise, EOF is returned
35       and errno is set to indicate the error.
36

ERRORS

38       EBADF  stream is not an open stream, or is not open for writing.
39
40       The function fflush() may also fail and set errno for any of the errors
41       specified for write(2).
42

ATTRIBUTES

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

STANDARDS

54       C11, POSIX.1-2008.
55

HISTORY

57       C89, POSIX.1-2001, POSIX.1-2008.
58
59       POSIX.1-2001 did  not  specify  the  behavior  for  flushing  of  input
60       streams, but the behavior is specified in POSIX.1-2008.
61

NOTES

63       Note  that fflush() flushes only the user-space buffers provided by the
64       C library.  To ensure that the data is physically stored  on  disk  the
65       kernel  buffers  must  be  flushed  too,  for  example, with sync(2) or
66       fsync(2).
67

SEE ALSO

69       fsync(2), sync(2), write(2), fclose(3), fileno(3), fopen(3), fpurge(3),
70       setbuf(3), unlocked_stdio(3)
71
72
73
74Linux man-pages 6.05              2023-07-20                         fflush(3)
Impressum