BSD 4 development
[unix-history] / usr / man / man2 / close.2
.TH CLOSE 2
.UC 4
.SH NAME
close \- close a file
.SH SYNOPSIS
.B close(fildes)
.SH DESCRIPTION
Given
a file descriptor such as returned from an
.I open,
.I creat,
.I dup
or
.IR pipe (2)
call,
.I close
closes the associated file.
A close of all files is automatic on
.I exit,
but since
there is a limit on the number of open files per process,
.I close
is necessary for programs which deal with many files.
.PP
Files are closed upon termination of a process, and
certain high-numbered file descriptors are closed by
.IR exec (2),
and it is possible to arrange for others to be closed
(see FIOCLEX in
.IR ioctl (2)).
.SH "SEE ALSO"
creat(2), open(2), pipe(2), exec(2), ioctl(2)
.SH DIAGNOSTICS
Zero is returned if a file is closed;
\-1 is returned for an unknown file descriptor.
.SH "ASSEMBLER (PDP-11)"
(close = 6.)
.br
(file descriptor in r0)
.br
.B sys close
.PP
.SH BUGS
A file cannot be closed while there are pages which have been
.I vread
but not referenced.