close(2)
NAME
close − close a file
SYNTAX
int close(fildes)
int fildes;
DESCRIPTION
Given a file descriptor returned from a creat, dup, fcntl, open, or pipe call, the close system call closes the file named by fildes. A close of all files is automatic on an exit call, but because there is a limit on the number of open files per process, the close call is necessary for programs which deal with many files.
All outstanding record locks on the file indicated by fildes that are owned by the calling process are removed.
Files are closed upon termination of a process, and certain file descriptors may be closed by the exec call.
RETURN VALUE
If unsuccessful, returns a −1, and the global variable errno indicates the error code.
DIAGNOSTICS
The close call will fail if:
[EBADF] The fildes argument is not an active descriptor.
ASSEMBLER
(close = 6.)
(file descriptor in r0)
sys close