close (system call)

Some programming languages maintain a data structure of files opened by their runtime library 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.

The close call is standardized by the POSIX specification 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.