close (system call)

Source: Wikipedia, the free encyclopedia.


A close system call is a

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. 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 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:

EBADF
The argument supplied was not a valid file descriptor
EINTR
The function call was interrupted by a signal
EIO
An
I/O error
occurred

References

External links