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