close()
QNX SDP8.0C Library ReferenceAPIDeveloper
Close a file
Synopsis:
#include <unistd.h>
int close( int filedes );
Arguments:
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The close() function closes the file specified by the given file descriptor.
Returns:
Zero for success, or -1 if an error occurs (errno is set).
Errors:
- EBADF
- Invalid file descriptor filedes.
- EINTR
- The close() call was interrupted by a signal. In the QNX OS implementation, the file descriptor remains open.
- EIO
- An I/O error occurred while updating the directory information.
- ENOSPC
- A previous buffered write call has failed.
- ENOSYS
- The close() function isn't implemented for the filesystem specified by filedes.
Examples:
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main( void )
{
int filedes;
filedes = open( "file", O_RDONLY );
if( filedes != -1 ) {
/* process file */
close( filedes );
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
Classification:
Safety: | |
---|---|
Cancellation point | Yes |
Signal handler | Yes |
Thread | Yes |
Page updated: