UNLINK(2)

NAME
unlink - remove directory entry

SYNOPSIS
#include <unistd.h>

int unlink (const char *path);

DESCRIPTION
The unlink function removes the link named by path from its directory and decrements the link count of the file which was referenced by the link. If that decrement reduces the link count of the file to zero, and no process has the file open, then all resources associated with the file are reclaimed. If one or more process have the file open when the last link is removed, the link is removed, but the removal of the file is delayed until all references to it have been closed.

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

BUGS
Under currently available filesystems, there can be only a single link to a given file.

The GNO unlink, unlike its UNIX counterpart, cannot currently unlink an open file. Attempting to do so will return an error, and the file will still exist when closed.

SEE ALSO
close(2), link(2), rmdir(2) symlink(7)

HISTORY
An unlink function call appeared in Version 6 AT&T UNIX.