]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/fflush.3
man*/: ffix (un-bracket tables)
[thirdparty/man-pages.git] / man3 / fflush.3
CommitLineData
a1eaacb1 1'\" t
fea681da
MK
2.\" Copyright (c) 1990, 1991 The Regents of the University of California.
3.\" All rights reserved.
4.\"
5.\" This code is derived from software contributed to Berkeley by
6.\" Chris Torek and the American National Standards Committee X3,
7.\" on Information Processing Systems.
8.\"
47009d5e 9.\" SPDX-License-Identifier: BSD-4-Clause-UC
fea681da
MK
10.\"
11.\" @(#)fflush.3 5.4 (Berkeley) 6/29/91
12.\"
13.\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
14.\"
e00c3a07 15.\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
fea681da
MK
16.\" Modified 2001-10-16 by John Levon <moz@compsoc.man.ac.uk>
17.\"
4c1c5274 18.TH fflush 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
19.SH NAME
20fflush \- flush a stream
afa8db94
AC
21.SH LIBRARY
22Standard C library
23.RI ( libc ", " \-lc )
fea681da 24.SH SYNOPSIS
c7db92b9 25.nf
fea681da 26.B #include <stdio.h>
68e4db0a 27.PP
cd03c9b8 28.BI "int fflush(FILE *_Nullable " stream );
c7db92b9 29.fi
fea681da 30.SH DESCRIPTION
2b64c171 31For output streams,
e511ffb6 32.BR fflush ()
fea681da
MK
33forces a write of all user-space buffered data for the given output or update
34.I stream
c13182ef 35via the stream's underlying write function.
847e0d88 36.PP
099263ce
MK
37For input streams associated with seekable files
38(e.g., disk files, but not pipes or terminals),
2b64c171
MK
39.BR fflush ()
40discards any buffered data that has been fetched from the underlying file,
20479b66 41but has not been consumed by the application.
847e0d88 42.PP
c13182ef 43The open status of the stream is unaffected.
fea681da
MK
44.PP
45If the
46.I stream
8478ee02 47argument is NULL,
e511ffb6 48.BR fflush ()
fea681da
MK
49flushes
50.I all
51open output streams.
76033537
MK
52.\" mtk: POSIX specifies that only output streams are flushed for this case.
53.\" Also verified for glibc by experiment.
fea681da 54.PP
24b74457 55For a nonlocking counterpart, see
fea681da 56.BR unlocked_stdio (3).
47297adb 57.SH RETURN VALUE
c13182ef
MK
58Upon successful completion 0 is returned.
59Otherwise,
fea681da 60.B EOF
9e39c4da 61is returned and
fea681da
MK
62.I errno
63is set to indicate the error.
64.SH ERRORS
65.TP
66.B EBADF
199431b6 67.I stream
fea681da
MK
68is not an open stream, or is not open for writing.
69.PP
70The function
e511ffb6 71.BR fflush ()
fea681da
MK
72may also fail and set
73.I errno
9e39c4da 74for any of the errors specified for
fea681da 75.BR write (2).
676420f2 76.SH ATTRIBUTES
0b8af3fa
MK
77For an explanation of the terms used in this section, see
78.BR attributes (7).
79.TS
80allbox;
c466875e 81lbx lb lb
0b8af3fa
MK
82l l l.
83Interface Attribute Value
84T{
9e54434e
BR
85.na
86.nh
676420f2 87.BR fflush ()
0b8af3fa
MK
88T} Thread safety MT-Safe
89.TE
c466875e 90.sp 1
3113c7f3 91.SH STANDARDS
4131356c
AC
92C11, POSIX.1-2008.
93.SH HISTORY
94C89, POSIX.1-2001, POSIX.1-2008.
847e0d88 95.PP
6db34ce8
MK
96POSIX.1-2001 did not specify the behavior for flushing of input streams,
97but the behavior is specified in POSIX.1-2008.
fea681da
MK
98.SH NOTES
99Note that
63aa9df0 100.BR fflush ()
1c709786 101flushes only the user-space buffers provided by the C library.
fea681da 102To ensure that the data is physically stored on disk
75b94dc3 103the kernel buffers must be flushed too, for example, with
fea681da
MK
104.BR sync (2)
105or
106.BR fsync (2).
47297adb 107.SH SEE ALSO
fea681da
MK
108.BR fsync (2),
109.BR sync (2),
110.BR write (2),
111.BR fclose (3),
f65efcf5 112.BR fileno (3),
fea681da 113.BR fopen (3),
85a7ae73 114.BR fpurge (3),
fea681da
MK
115.BR setbuf (3),
116.BR unlocked_stdio (3)