TIOCGPGRP copies an int out of the kernel
[unix-history] / usr / src / lib / libc / stdio / fclose.3
CommitLineData
639aed4c
KB
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
22f1f128 3.\"
639aed4c
KB
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\"
7.\" %sccs.include.redist.man%
8.\"
b07885fe 9.\" @(#)fclose.3 6.5 (Berkeley) %G%
639aed4c
KB
10.\"
11.TH FCLOSE 3 ""
12.UC 7
22f1f128 13.SH NAME
639aed4c 14fclose \- close a stream
22f1f128 15.SH SYNOPSIS
639aed4c
KB
16.nf
17.ft B
18#include <stdio.h>
19
20int
21fclose(FILE *stream);
22.ft R
23.fi
22f1f128
KM
24.SH DESCRIPTION
25.I Fclose
639aed4c 26dissociates the named
e6ecb2ae 27.I stream
639aed4c
KB
28from its underlying file or set of functions.
29If the stream was being used for output, any buffered data is written
30first, using
31.IR fflush (3).
639aed4c
KB
32.SH "RETURN VALUE"
33Upon successful completion 0 is returned.
34Otherwise,
22f1f128 35.B EOF
639aed4c
KB
36is returned and the global variable
37.I errno
38is set to indicate the error.
39In either case no further access to the stream is possible.
40.SH ERRORS
41.TP 15
42[EBADF]
43.I Stream
44is not an open stream.
45.PP
46.I Fclose
47may also fail and set
48.I errno
49for any of the errors specified for the routines
50.IR close (2)
51or
52.IR fflush (3).
53.SH STANDARDS
54.I Fclose
55conforms to ANSI X3.159-1989 (``ANSI C'').
b07885fe
KB
56.SH "SEE ALSO"
57close(2), fflush(3), fopen(3), setbuf(3)