1remove(3)                  Library Functions Manual                  remove(3)
2
3
4

NAME

6       remove - remove a file or directory
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <stdio.h>
13
14       int remove(const char *pathname);
15

DESCRIPTION

17       remove()  deletes  a  name from the filesystem.  It calls unlink(2) for
18       files, and rmdir(2) for directories.
19
20       If the removed name was the last link to a file and no  processes  have
21       the  file  open, the file is deleted and the space it was using is made
22       available for reuse.
23
24       If the name was the last link to a file, but any processes  still  have
25       the  file  open,  the file will remain in existence until the last file
26       descriptor referring to it is closed.
27
28       If the name referred to a symbolic link, the link is removed.
29
30       If the name referred to a socket, FIFO, or device, the name is removed,
31       but processes which have the object open may continue to use it.
32

RETURN VALUE

34       On  success,  zero is returned.  On error, -1 is returned, and errno is
35       set to indicate the error.
36

ERRORS

38       The errors that occur are those for unlink(2) and rmdir(2).
39

ATTRIBUTES

41       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
42       tributes(7).
43
44       ┌────────────────────────────────────────────┬───────────────┬─────────┐
45Interface                                   Attribute     Value   
46       ├────────────────────────────────────────────┼───────────────┼─────────┤
47remove()                                    │ Thread safety │ MT-Safe │
48       └────────────────────────────────────────────┴───────────────┴─────────┘
49

STANDARDS

51       C11, POSIX.1-2008.
52

HISTORY

54       POSIX.1-2001, C89, 4.3BSD.
55

BUGS

57       Infelicities  in  the  protocol underlying NFS can cause the unexpected
58       disappearance of files which are still being used.
59

SEE ALSO

61       rm(1), unlink(1), link(2), mknod(2), open(2), rename(2), rmdir(2),  un‐
62       link(2), mkfifo(3), symlink(7)
63
64
65
66Linux man-pages 6.04              2023-03-30                         remove(3)
Impressum