OSDN Git Service

(split) LDP_man-pages: update original to v3.34.
[linuxjm/LDP_man-pages.git] / original / 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 .\" 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  2009-09-06 "GNU" "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 For output streams,
52 .BR 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.
56 For input streams,
57 .BR fflush ()
58 discards any buffered data that has been fetched from the underlying file,
59 but has not been consumed by the application.
60 The open status of the stream is unaffected.
61 .PP
62 If the
63 .I stream
64 argument is NULL,
65 .BR fflush ()
66 flushes
67 .I all
68 open output streams.
69 .PP
70 For a nonlocking counterpart, see
71 .BR unlocked_stdio (3).
72 .SH "RETURN VALUE"
73 Upon successful completion 0 is returned.
74 Otherwise,
75 .B EOF
76 is returned and
77 .I errno
78 is set to indicate the error.
79 .SH ERRORS
80 .TP
81 .B EBADF
82 .I Stream
83 is not an open stream, or is not open for writing.
84 .PP
85 The function
86 .BR fflush ()
87 may also fail and set
88 .I errno
89 for any of the errors specified for
90 .BR write (2).
91 .SH "CONFORMING TO"
92 C89, C99, POSIX.1-2001, POSIX.1-2008.
93
94 The standards do not specify the behavior for input streams.
95 Most other implementations behave the same as Linux.
96 .\" Verified on: Solaris 8.
97 .SH NOTES
98 Note that
99 .BR fflush ()
100 only flushes 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 fopen (3),
112 .BR setbuf (3),
113 .BR unlocked_stdio (3)