make it possible to compile new versions of db that load against
[unix-history] / usr / src / lib / libc / stdio / fflush.3
CommitLineData
7860c229
KB
1.\" Copyright (c) 1990, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
48ffd455
KB
3.\"
4.\" This code is derived from software contributed to Berkeley by
043368e6
KB
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
48ffd455
KB
8.\" %sccs.include.redist.man%
9.\"
7860c229 10.\" @(#)fflush.3 8.1 (Berkeley) %G%
48ffd455 11.\"
ae59e04c
CL
12.Dd
13.Dt FFLUSH 3
14.Os
15.Sh NAME
16.Nm fflush ,
17.Nm fpurge
18.Nd flush a stream
19.Sh SYNOPSIS
20.Fd #include <stdio.h>
21.Ft int
22.Fn fflush "FILE *stream"
23.Ft int
24.Fn fpurge "FILE *stream"
25.Sh DESCRIPTION
26The function
27.Fn fflush
28forces a write of all buffered data for the given output or update
29.Fa stream
48ffd455 30via the stream's underlying write function.
ae59e04c
CL
31The open status of the stream is unaffected.
32.Pp
48ffd455 33If the
ae59e04c
CL
34.Fa stream
35argument is
36.Dv NULL ,
37.Fn fflush
48ffd455 38flushes
ae59e04c 39.Em all
48ffd455 40open output streams.
ae59e04c
CL
41.Pp
42The function
43.Fn fpurge
48ffd455 44erases any input or output buffered in the given
ae59e04c 45.Fa stream .
48ffd455
KB
46For output streams this discards any unwritten output.
47For input streams this discards any input read from the underlying object
48but not yet obtained via
ae59e04c 49.Xr getc 3 ;
48ffd455 50this includes any text pushed back via
ae59e04c
CL
51.Xr ungetc .
52.Sh RETURN VALUES
48ffd455
KB
53Upon successful completion 0 is returned.
54Otherwise,
ae59e04c 55.Dv EOF
48ffd455 56is returned and the global variable
ae59e04c 57.Va errno
48ffd455 58is set to indicate the error.
ae59e04c
CL
59.Sh ERRORS
60.Bl -tag -width [EBADF]
61.It Bq Er EBADF
62.Fa Stream
48ffd455 63is not an open stream, or, in the case of
ae59e04c 64.Fn fflush ,
48ffd455 65not a stream open for writing.
ae59e04c
CL
66.El
67.Pp
68The function
69.Fn fflush
48ffd455 70may also fail and set
ae59e04c 71.Va errno
48ffd455 72for any of the errors specified for the routine
ae59e04c
CL
73.Xr write 2 .
74.Sh SEE ALSO
75.Xr write 2 ,
76.Xr fopen 3 ,
77.Xr fclose 3 ,
78.Xr setbuf 3
79.Sh STANDARDS
80The
81.Fn fflush
82function
83conforms to
84.St -ansiC .