Commit | Line | Data |
---|---|---|
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 | |
10 | close \- close a file | |
11 | .SH SYNOPSIS | |
12 | .B close(fildes) | |
13 | .SH DESCRIPTION | |
14 | Given | |
15 | a file descriptor such as returned from an | |
16 | .I open, | |
17 | .I creat, | |
18 | .I dup | |
19 | or | |
20 | .IR pipe (2) | |
21 | call, | |
22 | .I close | |
23 | closes the associated file. | |
24 | A close of all files is automatic on | |
25 | .I exit, | |
26 | but since | |
27 | there is a limit on the number of open files per process, | |
28 | .I close | |
29 | is necessary for programs which deal with many files. | |
30 | .PP | |
31 | Files are closed upon termination of a process, and | |
32 | certain high-numbered file descriptors are closed by | |
33 | .IR exec (2), | |
34 | and it is possible to arrange for others to be closed | |
35 | (see FIOCLEX in | |
36 | .IR ioctl (2)). | |
37 | .SH "SEE ALSO" | |
38 | creat(2), open(2), pipe(2), exec(2), ioctl(2) | |
39 | .SH DIAGNOSTICS | |
40 | Zero 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 | |
50 | A file cannot be closed while there are pages which have been | |
51 | .I vread | |
52 | but not referenced. |