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