]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/fclose.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[thirdparty/man-pages.git] / man3 / fclose.3
CommitLineData
fea681da
MK
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.\"
a9cd9cb7 8.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
fea681da
MK
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\" must display the following acknowledgement:
19.\" This product includes software developed by the University of
20.\" California, Berkeley and its contributors.
21.\" 4. Neither the name of the University nor the names of its contributors
22.\" may be used to endorse or promote products derived from this software
23.\" without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35.\" SUCH DAMAGE.
8c9302dc 36.\" %%%LICENSE_END
fea681da
MK
37.\"
38.\" @(#)fclose.3 6.7 (Berkeley) 6/29/91
39.\"
40.\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
41.\"
e00c3a07 42.\" Modified 2000-07-22 by Nicolás Lichtmaier <nick@debian.org>
fea681da 43.\"
35deeb87 44.TH FCLOSE 3 2016-12-12 "GNU" "Linux Programmer's Manual"
fea681da
MK
45.SH NAME
46fclose \- close a stream
47.SH SYNOPSIS
48.B #include <stdio.h>
68e4db0a 49.PP
300791ed 50.BI "int fclose(FILE *" stream );
fea681da
MK
51.SH DESCRIPTION
52The
e511ffb6 53.BR fclose ()
c0adf09e 54function flushes the stream pointed to by
300791ed 55.I stream
fea681da
MK
56(writing any buffered output data using
57.BR fflush (3))
0dc60a99 58and closes the underlying file descriptor.
47297adb 59.SH RETURN VALUE
1ca319af 60Upon successful completion, 0 is returned.
c13182ef 61Otherwise,
fea681da 62.B EOF
0dc60a99 63is returned and
fea681da 64.I errno
c13182ef 65is set to indicate the error.
1ca319af 66In either case, any further access
fea681da
MK
67(including another call to
68.BR fclose ())
d9bfdb9c 69to the stream results in undefined behavior.
fea681da
MK
70.SH ERRORS
71.TP
72.B EBADF
9fdfa163 73The file descriptor underlying
300791ed 74.I stream
fea681da
MK
75is not valid.
76.\" This error cannot occur unless you are mixing ANSI C stdio operations and
77.\" low-level file operations on the same stream. If you do get this error,
78.\" you must have closed the stream's low-level file descriptor using
300791ed 79.\" something like close(fileno(stream)).
fea681da
MK
80.PP
81The
e511ffb6 82.BR fclose ()
fea681da
MK
83function may also fail and set
84.I errno
85for any of the errors specified for the routines
86.BR close (2),
1ca319af 87.BR write (2),
fea681da
MK
88or
89.BR fflush (3).
87314159
MS
90.SH ATTRIBUTES
91For an explanation of the terms used in this section, see
92.BR attributes (7).
93.TS
94allbox;
95lb lb lb
96l l l.
97Interface Attribute Value
98T{
99.BR fclose ()
100T} Thread safety MT-Safe
101.TE
47297adb 102.SH CONFORMING TO
56d5ba64 103POSIX.1-2001, POSIX.1-2008, C89, C99.
fea681da
MK
104.SH NOTES
105Note that
e511ffb6 106.BR fclose ()
f3f1456f 107flushes only the user-space buffers provided by the
c13182ef
MK
108C library.
109To ensure that the data is physically stored
75b94dc3 110on disk the kernel buffers must be flushed too, for example, with
fea681da
MK
111.BR sync (2)
112or
113.BR fsync (2).
47297adb 114.SH SEE ALSO
fea681da
MK
115.BR close (2),
116.BR fcloseall (3),
117.BR fflush (3),
f65efcf5 118.BR fileno (3),
fea681da
MK
119.BR fopen (3),
120.BR setbuf (3)