Penguin
Annotated edit history of close(2) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2
3 close - close a file descriptor
4 !!SYNOPSIS
5
6
2 PerryLorier 7 __#include <unistd.h>__
8 __int close( int__ ''fd''__);__
1 perry 9 !!DESCRIPTION
10
2 PerryLorier 11 __close__ closes a file descriptor, so that it no longer refers to any file and may be reused. Any locks held on the file it was associated with, and owned by the process, are removed (regardless of the file descriptor that was used to obtain the lock).
1 perry 12
2 PerryLorier 13 If ''fd'' is the last copy of a particular file descriptor the resources associated with it are freed; if the descriptor was the last reference to a file which has been removed using unlink(2) the file is deleted.
1 perry 14 !!RETURN VALUE
15
2 PerryLorier 16 __close__ returns zero on success, or -1 if an error occurred.
1 perry 17 !!ERRORS
18
2 PerryLorier 19 ;[EBADF]: ''fd'' isn't a valid open file descriptor, probably was never opened, or has been previously closed
20 ;[EINTR]: The __close__() call was interrupted by a signal.
21 ;[EIO]: An I/O error occurred.
1 perry 22
23 !!CONFORMING TO
24
2 PerryLorier 25 SVr4, SVID, POSIX, X/OPEN, BSD 4.3. SVr4 documents an additional [ENOLINK] error condition.
1 perry 26
27 !!NOTES
28
2 PerryLorier 29 Not checking the return value of close is a common but nevertheless serious programming error. File system implementations which use techniques as ``write-behind'' to increase performance may lead to write(2) succeeding, although the data has not been written yet. The error status
30 may be reported at a later write operation, but it is guaranteed to be reported on closing the file. Not checking the return value when closing the file may lead to silent loss of data. This can especially be observed with NFS and disk quotas.
1 perry 31
2 PerryLorier 32 A successful close does not guarantee that the data has been successfully saved to disk, as the kernel defers writes. It is not common for a filesystem to flush the buffers when the stream is closed. If you need to be sure that the data is physically stored use fsync(2) or sync(2), they will get you closer to that goal (it will depend on the disk hardware at this point).
1 perry 33
34 !!SEE ALSO
35
2 PerryLorier 36 open(2), fcntl(2), shutdown(2), unlink(2), fclose(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 5 times)