close a file at the operating-system level
#include <unistd.h> int close( int filedes );
The close() function closes a file at the operating-system level. The filedes value is the file descriptor returned by a successful execution of one of the creat(), dup(), dup2(), fcntl(), open() or sopen() functions.
#include <fcntl.h>
#include <unistd.h>
void main()
{
int filedes;
filedes = open( "file", O_RDONLY );
if( filedes != -1 ) {
/* process file */
close( filedes );
}
}
POSIX 1003.1
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
creat(), dup(), dup2(), errno, fcntl(), open(), sopen()