manual page distributed with 4.1BSD
[unix-history] / usr / src / lib / libc / sys / close.2
CommitLineData
6fd5737e
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)close.2 4.1 (Berkeley) %G%
6.\"
7.TH CLOSE 2
8.UC 4
9.SH NAME
10close \- close a file
11.SH SYNOPSIS
12.B close(fildes)
13.SH DESCRIPTION
14Given
15a file descriptor such as returned from an
16.I open,
17.I creat,
18.I dup
19or
20.IR pipe (2)
21call,
22.I close
23closes the associated file.
24A close of all files is automatic on
25.I exit,
26but since
27there is a limit on the number of open files per process,
28.I close
29is necessary for programs which deal with many files.
30.PP
31Files are closed upon termination of a process, and
32certain high-numbered file descriptors are closed by
33.IR exec (2),
34and it is possible to arrange for others to be closed
35(see FIOCLEX in
36.IR ioctl (2)).
37.SH "SEE ALSO"
38creat(2), open(2), pipe(2), exec(2), ioctl(2)
39.SH DIAGNOSTICS
40Zero is returned if a file is closed;
41\-1 is returned for an unknown file descriptor.
42.SH "ASSEMBLER (PDP-11)"
43(close = 6.)
44.br
45(file descriptor in r0)
46.br
47.B sys close
48.PP
49.SH BUGS
50A file cannot be closed while there are pages which have been
51.I vread
52but not referenced.