Debian Codegraph @

upstream/debian-unstable/man3/remove.3

raw
1 '\" t
2 .\" Copyright 1992, Drew Eckhardt <[email protected]>
3 .\" Copyright 1993, Ian Jackson <[email protected]>
4 .\" Copyright, the authors of the Linux man-pages project
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .TH remove 3 2026-02-08 "Linux man-pages 6.18"
9 .SH NAME
10 remove \- remove a file or directory
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .B #include <stdio.h>
17 .P
18 .BI "int remove(const char *" path );
19 .fi
20 .SH DESCRIPTION
21 .BR remove ()
22 deletes a name from the filesystem.
23 It calls
24 .BR unlink (2)
25 for files, and
26 .BR rmdir (2)
27 for directories.
28 .P
29 If the removed name was the
30 last link to a file and no processes have the file open, the file is
31 deleted and the space it was using is made available for reuse.
32 .P
33 If the name was the last link to a file,
34 but any processes still have the file open,
35 the file will remain in existence until the last file
36 descriptor referring to it is closed.
37 .P
38 If the name referred to a symbolic link, the link is removed.
39 .P
40 If the name referred to a socket, FIFO, or device, the name is removed,
41 but processes which have the object open may continue to use it.
42 .SH RETURN VALUE
43 On success, zero is returned.
44 On error, \-1 is returned, and
45 .I errno
46 is set to indicate the error.
47 .SH ERRORS
48 The errors that occur are those for
49 .BR unlink (2)
50 and
51 .BR rmdir (2).
52 .SH ATTRIBUTES
53 For an explanation of the terms used in this section, see
54 .BR attributes (7).
55 .TS
56 allbox;
57 lbx lb lb
58 l l l.
59 Interface Attribute Value
60 T{
61 .na
62 .nh
63 .BR remove ()
64 T} Thread safety MT-Safe
65 .TE
66 .SH STANDARDS
67 C11, POSIX.1-2008.
68 .SH HISTORY
69 POSIX.1-2001, C89, 4.3BSD.
70 .\" .SH NOTES
71 .\" Under libc4 and libc5,
72 .\" .BR remove ()
73 .\" was an alias for
74 .\" .BR unlink (2)
75 .\" (and hence would not remove directories).
76 .SH BUGS
77 Infelicities in the protocol underlying NFS can cause the unexpected
78 disappearance of files which are still being used.
79 .SH SEE ALSO
80 .BR rm (1),
81 .BR unlink (1),
82 .BR link (2),
83 .BR mknod (2),
84 .BR open (2),
85 .BR rename (2),
86 .BR rmdir (2),
87 .BR unlink (2),
88 .BR mkfifo (3),
89 .BR symlink (7)