UNLINK(2) SysV UNLINK(2)
NAME
unlink - remove directory entry
SYNOPSIS
int unlink (path)
char *path;
DESCRIPTION
unlink removes the directory entry pointed to by path.
If this entry was the last link to the file and no process has the file
open, the system frees the space occupied by the file and the file ceases
to exist. If a process has the file open, the system postpones the
removal until all references to the file have been closed.
ERRORS
The unlink succeeds unless one or more of the following are true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied for a component of the path
prefix.
[EACCES] Write permission is denied on the directory containing the
link to be removed.
[EPERM] The named file is a directory and the effective user ID of
the process is not super-user.
[EBUSY] The entry to be unlinked is the mount point for a mounted
file system.
[ETXTBSY] The entry to be unlinked is the last link to a pure
procedure (shared text) file that is being executed.
[EROFS] The directory entry to be unlinked is part of a read-only
file system.
[EFAULT] path points outside the process' allocated address space.
[EINTR] A signal was caught during the unlink system call.
SEE ALSO
close(2), link(2), open(2).
rm(1) in the SysV Command Reference.
DIAGNOSTICS
A successful call returns 0. A failed call returns -1 and sets errno as
indicated under "Errors."
NOTES
Under other implementations, unlink fails if either of the following is
true:
[ENOLINK] path points to a remote machine and the link to that
machine is no longer active.
[EMULTIHOP] Components of path require hopping to multiple remote
machines.