unlink(2) CLIX unlink(2)
NAME
unlink - Removes a directory entry
LIBRARY
Standard C Library - (libc.a)
SYNOPSIS
int unlink(
char *path );
PARAMETERS
path Specifies the directory entry to be removed.
DESCRIPTION
The unlink() function removes the directory entry specified by path.
When all links to a file are removed and no process has the file open, all
resources associated with the file are reclaimed, and the file is no
longer accessible. If one or more processes have the file open when the
last link is removed, the directory entry disappears, but the removal of
the file contents is postponed until all references to the file are
closed.
EXAMPLES
if (unlink("/usr/tmp/testdir") == -1)
perror("unlink failed");
RETURN VALUES
Upon successful completion, a value of 0 is returned. If unlink() fails,
a value of -1 is returned, and the global variable errno is set to
indicate the error.
ERRORS
The unlink() function fails and the named file is not unlinked if one or
more of the following are true:
[ENOENT]
The named file does not exist.
[EACCES]
Search permission is denied for a component of the path prefix or
write permission is denied on the directory containing the link to
2/94 - Intergraph Corporation 1
unlink(2) CLIX unlink(2)
be removed.
[EPERM]
The named file is a directory, and the calling process is not
superuser.
[EBUSY]
The entry to be unlinked is the mount point for a mounted file
system.
[EROFS]
The entry to be unlinked is part of a read-only file system.
[ENAMETOOLONG]
The length of path exceeds PATH_MAX, or a pathname component is
longer than NAME_MAX while _POSIX_NO_TRUNC is in effect.
[ENOTDIR]
A component of the path prefix is not a directory.
[ETXTBSY]
The entry to be unlinked is the last link to a pure procedure
(shared text) file that is being executed.
[EFAULT]
The path parameter points outside the process's allocated address
space.
[EINTR]
A signal was caught during the unlink() function.
[ENOLINK]
The path parameter 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.
RELATED INFORMATION
Commands: rm(1)
Functions: close(2), link(2), open(2), rmdir(2)
2 Intergraph Corporation - 2/94