]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/fclose.3
Convert to American spelling conventions
[thirdparty/man-pages.git] / man3 / fclose.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 .\" @(#)fclose.3 6.7 (Berkeley) 6/29/91
37 .\"
38 .\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
39 .\"
40 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
41 .\"
42 .TH FCLOSE 3 1993-11-29 "GNU" "Linux Programmer's Manual"
43 .SH NAME
44 fclose \- close a stream
45 .SH SYNOPSIS
46 .B #include <stdio.h>
47 .sp
48 .BI "int fclose(FILE *" fp );
49 .SH DESCRIPTION
50 The
51 .BR fclose ()
52 function will flush the stream pointed to by
53 .IR fp
54 (writing any buffered output data using
55 .BR fflush (3))
56 and close the underlying file descriptor.
57 .SH "RETURN VALUE"
58 Upon successful completion 0 is returned.
59 Otherwise,
60 .B EOF
61 is returned and the global variable
62 .I errno
63 is set to indicate the error.
64 In either case any further access
65 (including another call to
66 .BR fclose ())
67 to the stream results in undefined behavior.
68 .SH ERRORS
69 .TP
70 .B EBADF
71 The file descriptor underlying
72 .I fp
73 is not valid.
74 .\" This error cannot occur unless you are mixing ANSI C stdio operations and
75 .\" low-level file operations on the same stream. If you do get this error,
76 .\" you must have closed the stream's low-level file descriptor using
77 .\" something like close(fileno(fp)).
78 .PP
79 The
80 .BR fclose ()
81 function may also fail and set
82 .I errno
83 for any of the errors specified for the routines
84 .BR close (2),
85 .BR write (2)
86 or
87 .BR fflush (3).
88 .SH "CONFORMING TO"
89 C89, C99.
90 .SH NOTES
91 Note that
92 .BR fclose ()
93 only flushes the user space buffers provided by the
94 C library.
95 To ensure that the data is physically stored
96 on disk the kernel buffers must be flushed too, e.g. with
97 .BR sync (2)
98 or
99 .BR fsync (2).
100 .SH "SEE ALSO"
101 .BR close (2),
102 .BR fcloseall (3),
103 .BR fflush (3),
104 .BR fopen (3),
105 .BR setbuf (3)