World Library  
Flag as Inappropriate
Email this Article

Close (system call)

Article Id: WHEBN0032029777
Reproduction Date:

Title: Close (system call)  
Author: World Heritage Encyclopedia
Language: English
Subject: Linux kernel, Open (system call), C POSIX library, Dup (system call), File system API
Collection: C Posix Library, System Calls
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Close (system call)

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) 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 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

POSIX close

This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.