share/mk/: build-html: Don't build mbind.2 and set_mempolicy.2
[man-pages.git] / man3 / fclose.3
blobc8d044b9ceed2479bfe08b456ad1ed70eac7c903
1 '\" t
2 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
3 .\" All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Chris Torek and the American National Standards Committee X3,
7 .\" on Information Processing Systems.
8 .\"
9 .\" SPDX-License-Identifier: BSD-4-Clause-UC
10 .\"
11 .\"     @(#)fclose.3    6.7 (Berkeley) 6/29/91
12 .\"
13 .\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
14 .\"
15 .\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
16 .\"
17 .TH fclose 3 (date) "Linux man-pages (unreleased)"
18 .SH NAME
19 fclose \- close a stream
20 .SH LIBRARY
21 Standard C library
22 .RI ( libc ", " \-lc )
23 .SH SYNOPSIS
24 .nf
25 .B #include <stdio.h>
27 .BI "int fclose(FILE *" stream );
28 .fi
29 .SH DESCRIPTION
30 The
31 .BR fclose ()
32 function flushes the stream pointed to by
33 .I stream
34 (writing any buffered output data using
35 .BR fflush (3))
36 and closes the underlying file descriptor.
37 .SH RETURN VALUE
38 Upon successful completion, 0 is returned.
39 Otherwise,
40 .B EOF
41 is returned and
42 .I errno
43 is set to indicate the error.
44 In either case, any further access
45 (including another call to
46 .BR fclose ())
47 to the stream results in undefined behavior.
48 .SH ERRORS
49 .TP
50 .B EBADF
51 The file descriptor underlying
52 .I stream
53 is not valid.
54 .\"  This error cannot occur unless you are mixing ANSI C stdio operations and
55 .\"  low-level file operations on the same stream. If you do get this error,
56 .\"  you must have closed the stream's low-level file descriptor using
57 .\"  something like close(fileno(stream)).
59 The
60 .BR fclose ()
61 function may also fail and set
62 .I errno
63 for any of the errors specified for the routines
64 .BR close (2),
65 .BR write (2),
67 .BR fflush (3).
68 .SH ATTRIBUTES
69 For an explanation of the terms used in this section, see
70 .BR attributes (7).
71 .TS
72 allbox;
73 lbx lb lb
74 l l l.
75 Interface       Attribute       Value
77 .na
78 .nh
79 .BR fclose ()
80 T}      Thread safety   MT-Safe
81 .TE
82 .SH STANDARDS
83 C11, POSIX.1-2008.
84 .SH HISTORY
85 C89, POSIX.1-2001.
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)
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)