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