close()

close file descriptor 

Function


SYNOPSIS

#include <unistd.h>

int close(int fildes);


DESCRIPTION

The close() function deallocates the file specified descriptor. To deallocate means to make the file descriptor available for subsequent calls to open() or other functions that allocate file descriptors. All outstanding record locks owned by the process on the file associated with the file descriptor are removed.

If close() is interrupted by a signal that is to be caught, it returns -1 with errno set to EINTR, and the state of the file descriptor is unspecified.

When all file descriptors associated with a pipe or FIFO special file are closed, any data remaining in the pipe of FIFO is discarded.

When all file descriptors associated with an open file description have been closed, the open file description freed.

If the link count of a file is 0, when all file descriptors associated with the file are closed, the space occupied by the file is freed and the file is no longer accessible.


PARAMETERS

fildes 

Indicates the file descriptor to close.


RETURN VALUES

If successful, close() returns a value of zero. On failure, it returns a value of -1 and sets errno to one of the following:

EBADF 

fildes is not a valid file descriptor.

EINTR 

A signal interrupted the call.


CONFORMANCE

POSIX.1 (1996), with exceptions.


MULTITHREAD SAFETY LEVEL

Async-signal-safe.


PORTING ISSUES

If the file was opened with an attribute of O_TEMPORARY, the file is deleted if the count is zero.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
fcntl(), open(), unlink()


PTC MKS Toolkit 10.4 Documentation Build 39.