CLOSE(2)

NAME
close - delete a descriptor

SYNOPSIS
#include <unistd.h>

int close(int fd);

DESCRIPTION
The close call deletes a descriptor from the per-process file descriptor table. If this is the last reference to the underlying object, the object will be deactivated. For example, on the last close of a file the current seek pointer associated with the file is lost; on the last close of a socket(2) associated naming information and queued data are discarded; on the last close of a file holding an advisory lock the lock is released (see further flock(2)).

RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and the global integer variable errno is set to indicate the error.

ERRORS
Close will fail if:

    EBADF
        fd is not an active descriptor.

    EINTR
        An interrupt was received.

SEE ALSO
accept(2), flock(2), open(2), pipe(2), socket(2), socketpair(2), execve(2), fcntl(2)

STANDARDS
close conforms to IEEE Std 1003.1-1988 (POSIX).