HOME

TheInfoList



OR:

A close system call is a system call used to close a file descriptor by the kernel. For most file systems, a
program Program, programme, programmer, or programming may refer to: Business and management * Program management, the process of managing several related projects * Time management * Program, a part of planning Arts and entertainment Audio * Programm ...
terminates access to a file in a filesystem using the close system call. This flushes file 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) and updates the system wide table of files in use. Some programming languages maintain a
data structure In computer science, a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, ...
of files opened by their
runtime library In computer programming, a runtime library is a set of low-level routines used by a compiler to invoke some of the behaviors of a runtime environment, by inserting calls to the runtime library into compiled executable binary. The runtime enviro ...
and may close when the program terminates. This practice is known as resource acquisition is initialization (RAII). Some operating systems will invoke the close on files held by a program if it terminates. Some operating systems will invoke the close syscall 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 The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming in ...
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: ; : The argument supplied was not a valid file descriptor ; : The function call was interrupted by a signal ; : An I/O error occurred


References


POSIX close


External links

* {{Computer files C POSIX library System calls