removeのヘルプ・マニュアル
日本語 英語
remove --help
man remove
REMOVE(3) Linux Programmer’s Manual REMOVE(3)
名前
remove - ファイルやディレクトリを削除する
書式
#include
int remove(const char *pathname);
説明
remove() はファイルシステムからファイル名を削除する。ファイルに対しては
unlink(2) を、ディレクトリに対しては rmdir(2) を呼び出す。
もしその名前がファイルへの最後のリンクで、かつ、どのプロセスもそのフ ァ
イ ルを開いていないなら、ファイルも削除する。ファイルの占めていた領域は
他で使うことができるようになる。
名前がファイルへの最後のリンクであっても、どこかのプロセスがそのファ イ
ルを開いているなら、ファイルの最後のファイル記述子 (file descriptor) が
閉じられるまでファイルは存在し続ける。
名前が指しているのがシンボリックリンクなら、そのリンクを削除する。
名前が指しているのがソケット、FIFO、デバイスの場合、名前は削除される が
、 そのソケットなどを開いているプロセスはそのまま使い続けることができる
。
返り値
成功すれば 0 が返る。エラーなら -1 が返り、 errno に適切な値がセット さ
れる。
エラー
発生するエラーは unlink(2) および rmdir(2) と同じものである。
準拠
C89, C99, 4.3BSD, POSIX.1-2001.
注意
libc4 と libc5 においては、 remove() は unlink(2) の別名であった (従っ
てディレクトリを削除できなかった)。
バグ
NFS プロトコルの根本的な不都合により、使用中のファイルが、想定できな い
形で削除されることがありえる。
関連項目
rm(1), unlink(1), link(2), mknod(2), open(2), rename(2), rmdir(2),
unlink(2), mkfifo(3), symlink(7)
GNU 2008-12-03 REMOVE(3)
REMOVE(3) Linux Programmer’s Manual REMOVE(3)
NAME
remove - remove a file or directory
SYNOPSIS
#include
int remove(const char *pathname);
DESCRIPTION
remove() deletes a name from the file system. It calls unlink(2) for
files, and rmdir(2) for directories.
If the removed name was the last link to a file and no processes have
the file open, the file is deleted and the space it was using is made
available for reuse.
If the name was the last link to a file, but any processes still have
the file open, the file will remain in existence until the last file
descriptor referring to it is closed.
If the name referred to a symbolic link, the link is removed.
If the name referred to a socket, FIFO, or device, the name is removed,
but processes which have the object open may continue to use it.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is
set appropriately.
ERRORS
The errors that occur are those for unlink(2) and rmdir(2).
CONFORMING TO
C89, C99, 4.3BSD, POSIX.1-2001.
NOTES
Under libc4 and libc5, remove() was an alias for unlink(2) (and hence
would not remove directories).
BUGS
Infelicities in the protocol underlying NFS can cause the unexpected
disappearance of files which are still being used.
SEE ALSO
rm(1), unlink(1), link(2), mknod(2), open(2), rename(2), rmdir(2),
unlink(2), mkfifo(3), symlink(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2008-12-03 REMOVE(3)