]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/fclose.3
All pages: Remove the 5th argument to .TH
[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 .\" SPDX-License-Identifier: BSD-4-Clause-UC
9 .\"
10 .\" @(#)fclose.3 6.7 (Berkeley) 6/29/91
11 .\"
12 .\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
13 .\"
14 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
15 .\"
16 .TH FCLOSE 3 2021-03-22 "Linux man-pages (unreleased)"
17 .SH NAME
18 fclose \- close a stream
19 .SH LIBRARY
20 Standard C library
21 .RI ( libc ", " \-lc )
22 .SH SYNOPSIS
23 .nf
24 .B #include <stdio.h>
25 .PP
26 .BI "int fclose(FILE *" stream );
27 .fi
28 .SH DESCRIPTION
29 The
30 .BR fclose ()
31 function flushes the stream pointed to by
32 .I stream
33 (writing any buffered output data using
34 .BR fflush (3))
35 and closes the underlying file descriptor.
36 .SH RETURN VALUE
37 Upon successful completion, 0 is returned.
38 Otherwise,
39 .B EOF
40 is returned and
41 .I errno
42 is set to indicate the error.
43 In either case, any further access
44 (including another call to
45 .BR fclose ())
46 to the stream results in undefined behavior.
47 .SH ERRORS
48 .TP
49 .B EBADF
50 The file descriptor underlying
51 .I stream
52 is not valid.
53 .\" This error cannot occur unless you are mixing ANSI C stdio operations and
54 .\" low-level file operations on the same stream. If you do get this error,
55 .\" you must have closed the stream's low-level file descriptor using
56 .\" something like close(fileno(stream)).
57 .PP
58 The
59 .BR fclose ()
60 function may also fail and set
61 .I errno
62 for any of the errors specified for the routines
63 .BR close (2),
64 .BR write (2),
65 or
66 .BR fflush (3).
67 .SH ATTRIBUTES
68 For an explanation of the terms used in this section, see
69 .BR attributes (7).
70 .ad l
71 .nh
72 .TS
73 allbox;
74 lbx lb lb
75 l l l.
76 Interface Attribute Value
77 T{
78 .BR fclose ()
79 T} Thread safety MT-Safe
80 .TE
81 .hy
82 .ad
83 .sp 1
84 .SH STANDARDS
85 POSIX.1-2001, POSIX.1-2008, C89, C99.
86 .SH NOTES
87 Note that
88 .BR fclose ()
89 flushes only the user-space buffers provided by the
90 C library.
91 To ensure that the data is physically stored
92 on disk the kernel buffers must be flushed too, for example, with
93 .BR sync (2)
94 or
95 .BR fsync (2).
96 .SH SEE ALSO
97 .BR close (2),
98 .BR fcloseall (3),
99 .BR fflush (3),
100 .BR fileno (3),
101 .BR fopen (3),
102 .BR setbuf (3)