MAN page from Old RedHat 5.X man-pages-1.21-1.noarch.rpm
CLOSE
Section: Linux Programmer's Manual (2)
Updated: April 14, 1996
Index NAME
close - close a file descriptor
SYNOPSIS
#include <unistd.h>int close(int fd);
DESCRIPTION
closecloses a file descriptor, so that it no longer refers to any file andmay be reused. Any locks held on the file it was associated with,and owned by the process, are removed (regardless of the filedescriptor that was used to obtain the lock).
Iffdis the last copy of a particular file descriptor the resourcesassociated with it are freed;if the descriptor was the last reference to a file which has beenremoved usingunlinkthe file is deleted.
RETURN VALUE
closereturns zero on success, or -1 if an error occurred.
ERRORS
- EBADF
- fdisn't a valid open file descriptor.
CONFORMING TO
SVr4, SVID, POSIX, X/OPEN, BSD 4.3. SVr4 documents an additionalENOLINK error condition.
NOTES
Not checking the return value of close is a common but neverthelessserious programming error. File system implementations which usetechniques as ``write-behind'' to increase performance may lead to
write(2)succeeding, although the data has not been written yet. The errorstatus may be reported at a later write operation, but it is guaranteedto be reported on closing the file. Not checking the return value whenclosing the file may lead to silent loss of data. This can especiallybe observed with NFS and disk quotas.
SEE ALSO
open(2),
fcntl(2),
shutdown(2),
unlink(2),
fclose(3).
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- RETURN VALUE
- ERRORS
- CONFORMING TO
- NOTES
- SEE ALSO
This document was created byman2html,using the manual pages.