Imported upstream version 1.5
[manpages-zh.git] / raw / man3 / fflush.3
blob159cb5149adfe0bf21a120572b17afb90d511d2f
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 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)fflush.3    5.4 (Berkeley) 6/29/91
37 .\"
38 .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
39 .\"
40 .\" Modified 2000-07-22 by Nicol??s Lichtmaier <nick@debian.org>
41 .\" Modified 2001-10-16 by John Levon <moz@compsoc.man.ac.uk>
42 .\"
43 .TH FFLUSH 3  1993-11-29 "BSD MANPAGE" "Linux Programmer's Manual"
44 .SH NAME
45 fflush \- flush a stream
46 .SH SYNOPSIS
47 .B #include <stdio.h>
48 .sp
49 .BI "int fflush(FILE *" stream );
50 .SH DESCRIPTION
51 The function
52 .B fflush
53 forces a write of all user-space buffered data for the given output or update
54 .I stream
55 via the stream's underlying write function.  The open status of the stream
56 is unaffected.
57 .PP
58 If the
59 .I stream
60 argument is
61 .BR NULL ,
62 .B fflush
63 flushes
64 .I all
65 open output streams.
66 .PP
67 For a non-locking counterpart, see
68 .BR unlocked_stdio (3).
69 .SH "RETURN VALUE"
70 Upon successful completion 0 is returned.  Otherwise,
71 .B EOF
72 is returned and the global variable
73 .I errno
74 is set to indicate the error.
75 .SH ERRORS
76 .TP
77 .B EBADF
78 .I Stream
79 is not an open stream, or is not open for writing.
80 .PP
81 The function
82 .B fflush
83 may also fail and set
84 .I errno
85 for any of the errors specified for the routine
86 .BR write (2).
87 .SH NOTES
88 Note that
89 .B fflush()
90 only flushes the user space buffers provided by the C library.
91 To ensure that the data is physically stored on disk
92 the kernel buffers must be flushed too, e.g. with
93 .BR sync (2)
95 .BR fsync (2).
96 .SH "CONFORMING TO"
97 The function
98 .BR fflush()
99 conforms to ANSI X3.159-1989 (``ANSI C'').
100 .SH "SEE ALSO"
101 .BR fsync (2),
102 .BR sync (2),
103 .BR write (2),
104 .BR fclose (3),
105 .BR fopen (3),
106 .BR setbuf (3),
107 .BR unlocked_stdio (3)