.TH CLOSE 2 .UC .SH NAME close \- close a file .SH SYNOPSIS .B close(fildes) .PP .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 file descriptors may be closed by .IR execve (2) (see .IR ioctl (2)). .SH RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Close will fail if: .TP 20 [EBADF] .I Fildes is not an active descriptor. .SH "SEE ALSO" creat(2), execve(2), ioctl(2), open(2), pipe(2) .SH ASSEMBLER (close = 6.) .br (file descriptor in r0) .br .B sys close