Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/close.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/close.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/close.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/close.html on line 8
Close a file
#include <unistd.h>
int close( int filedes );
- filedes
- The file descriptor of the file you want to close.
This can be a file descriptor returned by a successful call to
accept(),
creat(),
dup(),
dup2(),
fcntl(),
modem_open(),
open(),
shm_open(),
socket() or
sopen().
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The close() function closes the file specified by the given
file descriptor.
Zero for success, or -1 if an error occurs (errno is set).
- EBADF
- Invalid file descriptor filedes.
- EINTR
- The close() call was interrupted by a signal.
- 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.
#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;
}
POSIX 1003.1
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
accept(),
creat(),
dup(),
dup2(),
errno,
fcntl(),
modem_open(),
open(),
shm_open(),
socket(),
sopen()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/close.html on line 182
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/close.html on line 182