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.  For input streams, fflush() discards any buffered data
17       that has been fetched from the underlying file, but has not  been  con‐
18       sumed by the application.  The open status of the stream is unaffected.
19
20       If  the  stream  argument  is  NULL,  fflush()  flushes all open output
21       streams.
22
23       For a nonlocking counterpart, see unlocked_stdio(3).
24

RETURN VALUE

26       Upon successful completion 0 is returned.  Otherwise, EOF  is  returned
27       and errno is set to indicate the error.
28

ERRORS

30       EBADF  Stream is not an open stream, or is not open for writing.
31
32       The function fflush() may also fail and set errno for any of the errors
33       specified for write(2).
34

ATTRIBUTES

36   Multithreading (see pthreads(7))
37       The fflush() function is thread-safe.
38

CONFORMING TO

40       C89, C99, POSIX.1-2001, POSIX.1-2008.
41
42       The standards do not specify the  behavior  for  input  streams.   Most
43       other implementations behave the same as Linux.
44

NOTES

46       Note  that fflush() only flushes the user-space buffers provided by the
47       C library.  To ensure that the data is physically stored  on  disk  the
48       kernel  buffers  must  be  flushed  too,  for  example, with sync(2) or
49       fsync(2).
50

SEE ALSO

52       fsync(2),   sync(2),   write(2),   fclose(3),   fopen(3),    setbuf(3),
53       unlocked_stdio(3)
54

COLOPHON

56       This  page  is  part of release 3.53 of the Linux man-pages project.  A
57       description of the project, and information about reporting  bugs,  can
58       be found at http://www.kernel.org/doc/man-pages/.
59
60
61
62GNU                               2013-07-15                         FFLUSH(3)
Impressum