]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" This file is derived from unlink.2, which has the following copyright: |
2 | .\" | |
fea681da | 3 | .\" This manpage is Copyright (C) 1992 Drew Eckhardt; |
ac56b6a8 | 4 | .\" and Copyright (C) 1993 Ian Jackson. |
fea681da | 5 | .\" |
1fcd9102 MK |
6 | .\" Edited into remove.3 shape by: |
7 | .\" Graeme W. Wilford (G.Wilford@ee.surrey.ac.uk) on 13th July 1994 | |
8 | .\" | |
5fbde956 | 9 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da | 10 | .\" |
45186a5d | 11 | .TH REMOVE 3 2021-03-22 "Linux man-pages (unreleased)" |
fea681da | 12 | .SH NAME |
46c0fadf | 13 | remove \- remove a file or directory |
4d8af955 AC |
14 | .SH LIBRARY |
15 | Standard C library | |
8fc3b2cf | 16 | .RI ( libc ", " \-lc ) |
fea681da | 17 | .SH SYNOPSIS |
c7db92b9 | 18 | .nf |
fea681da | 19 | .B #include <stdio.h> |
68e4db0a | 20 | .PP |
fea681da | 21 | .BI "int remove(const char *" pathname ); |
c7db92b9 | 22 | .fi |
fea681da | 23 | .SH DESCRIPTION |
e511ffb6 | 24 | .BR remove () |
9ee4a2b6 | 25 | deletes a name from the filesystem. |
fea681da | 26 | It calls |
fb186734 | 27 | .BR unlink (2) |
fea681da | 28 | for files, and |
fb186734 | 29 | .BR rmdir (2) |
fea681da | 30 | for directories. |
847e0d88 | 31 | .PP |
fea681da | 32 | If the removed name was the |
46c0fadf | 33 | last link to a file and no processes have the file open, the file is |
fea681da | 34 | deleted and the space it was using is made available for reuse. |
847e0d88 | 35 | .PP |
46c0fadf MK |
36 | If the name was the last link to a file, |
37 | but any processes still have the file open, | |
38 | the file will remain in existence until the last file | |
fea681da | 39 | descriptor referring to it is closed. |
847e0d88 | 40 | .PP |
46c0fadf | 41 | If the name referred to a symbolic link, the link is removed. |
847e0d88 | 42 | .PP |
46c0fadf MK |
43 | If the name referred to a socket, FIFO, or device, the name is removed, |
44 | but processes which have the object open may continue to use it. | |
47297adb | 45 | .SH RETURN VALUE |
c13182ef MK |
46 | On success, zero is returned. |
47 | On error, \-1 is returned, and | |
fea681da | 48 | .I errno |
f6a4078b | 49 | is set to indicate the error. |
fea681da MK |
50 | .SH ERRORS |
51 | The errors that occur are those for | |
52 | .BR unlink (2) | |
53 | and | |
54 | .BR rmdir (2). | |
aaff622e | 55 | .SH ATTRIBUTES |
692646ca PH |
56 | For an explanation of the terms used in this section, see |
57 | .BR attributes (7). | |
c466875e MK |
58 | .ad l |
59 | .nh | |
692646ca PH |
60 | .TS |
61 | allbox; | |
c466875e | 62 | lbx lb lb |
692646ca PH |
63 | l l l. |
64 | Interface Attribute Value | |
65 | T{ | |
aaff622e | 66 | .BR remove () |
692646ca PH |
67 | T} Thread safety MT-Safe |
68 | .TE | |
c466875e MK |
69 | .hy |
70 | .ad | |
71 | .sp 1 | |
3113c7f3 | 72 | .SH STANDARDS |
88d3b8a9 | 73 | POSIX.1-2001, POSIX.1-2008, C89, C99, 4.3BSD. |
f5ccb6a7 MK |
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). | |
2b2581ee MK |
80 | .SH BUGS |
81 | Infelicities in the protocol underlying NFS can cause the unexpected | |
82 | disappearance of files which are still being used. | |
47297adb | 83 | .SH SEE ALSO |
fea681da | 84 | .BR rm (1), |
49ec013c | 85 | .BR unlink (1), |
fea681da MK |
86 | .BR link (2), |
87 | .BR mknod (2), | |
88 | .BR open (2), | |
89 | .BR rename (2), | |
90 | .BR rmdir (2), | |
91 | .BR unlink (2), | |
a9cfde1d MK |
92 | .BR mkfifo (3), |
93 | .BR symlink (7) |