unlink(2) unlink(2)
NAME
unlink, remove - remove directory entry
SYNOPSIS
int unlink (path)
char *path;
int remove (path)
char *path;
DESCRIPTION
unlink removes the directory entry named by the path name
pointed to by path.
Remove is an alternate name for unlink.
The named file is unlinked unless one or more of the follow-
ing are true:
[EACCES] Search permission is denied for a component
of the path prefix, or write permission is
denied on the directory containing the link
to be removed.
[EBUSY] The entry to be unlinked is the mount point
for a mounted file system.
[EFAULT] Path points outside the process's allocated
address space.
[ENAMETOOLONG] The path argument exceeds {PATH_MAX} in
length, or a pathname component is longer
than {NAME_MAX} (see pathconf(2)).
[ENOENT] The named file does not exist, or the path
argument points to an empty string.
[ENOTDIR] A component of the path prefix is not a
directory.
[EPERM] The named file is a directory and the effec-
tive user ID of the process is not super-
user.
[EROFS] The directory entry to be unlinked is part of
a read-only file system.
[ETXTBSY] The entry to be unlinked is the last link to
a pure procedure (shared text) file that is
being executed.
Page 1 CX/UX Programmer's Reference Manual
unlink(2) unlink(2)
When all links to a file have been removed and no process
has the file open, the space occupied by the file is freed
and the file ceases to exist. If one or more processes have
the file open when the last link is removed, the removal is
postponed until all references to the file have been closed.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned and errno is set to indi-
cate the error.
SEE ALSO
close(2), link(2), open(2), rmdir(2).
rm(1) in the CX/UX User's Reference Manual.
Page 2 CX/UX Programmer's Reference Manual