Close (system call)
Encyclopedia
For most file systems, a program terminates access to a file in a filesystem using the close system call. This flushes buffers, updates file metadata (which may include and end of file indicator in the data), de-allocates resources associated with the file (including the file descriptor
File descriptor
In computer programming, a file descriptor is an abstract indicator for accessing a file. The term is generally used in POSIX operating systems...

) and updates the system wide table of files in use. Some languages maintain a structure of files opened by its run-time library and may close when the program terminates. Some operating systems will invoke the close if the program terminates. Some operating systems will invoke the close as part of an operating system recovery as a result of a system failure.

C library POSIX definition

The close call is standardized by the POSIX
POSIX
POSIX , an acronym for "Portable Operating System Interface", is a family of standards specified by the IEEE for maintaining compatibility between operating systems...

 specification

int close (int filedes);
int fclose(FILE *stream);
The function returns zero to indicate the file was closed successfully. If any error occurs, a value of -1 is returned and errno is appropriately set.

The errors that can occur include:




EBADFThe argument supplied was not a valid file descriptor
EINTRThe function call was interrupted by a signal
Signal (computing)
A signal is a limited form of inter-process communication used in Unix, Unix-like, and other POSIX-compliant operating systems. Essentially it is an asynchronous notification sent to a process in order to notify it of an event that occurred. When a signal is sent to a process, the operating system...

EIOAn I/O error occurred
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK