CONTENTS | INDEX | PREV | NEXT
close
NAME
close - close a file descriptor
SYNOPSIS
int r = close(fd);
int fd;
FUNCTION
The specified file descriptor is closed. If an error occurs on
close or the descriptor is invalid a non-zero return code will
result and errno will be set to the appropriate error condition.
NOTE
refer to the file_descriptor manual page for general information
Unlike file pointers and file handles, the file descriptor is
checked for validity and will simply return an error if illegal.
EXAMPLE
#include <fcntl.h>
main()
{
int fd;
fd = open("T:xx", O_WRONLY|O_CREAT|O_TRUNC);
if (fd >= 0) {
puts("created empty file T:xx");
close(fd);
} else {
puts("unable to create T:xx");
}
return(0);
}
INPUTS
int fd; file descriptor to close, the file descriptor becomes
invalid after this call
RESULTS
int r; return value, 0 == ok, non-zero == error