[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rm -rf calls rmdir() prior to close(), which can fail
From: |
Paul Eggert |
Subject: |
Re: rm -rf calls rmdir() prior to close(), which can fail |
Date: |
Thu, 20 Oct 2011 12:47:28 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Thunderbird/3.1.15 |
On 10/20/11 10:38, Eric Blake wrote:
> POSIX is clear that attempts to rmdir() a directory that still has open
> descriptors may fail.
Hmm, that's news to me. And on the contrary, the spec
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html>
explicitly talks about what rmdir() does when there are open descriptors:
"If one or more processes have the directory open when the last link is
removed,
the dot and dot-dot entries, if present, shall be removed before rmdir()
returns
and no new entries may be created in the directory, but the directory shall
not
be removed until all references to the directory are closed."
which very much sounds like rmdir() is supposed to succeed in this case.
Also, there's no entry for this situation under the "may fail" section
of ERRORS. And there's longstanding Unix tradition that you can unlink
a file that you have an open file descriptor to, which suggests that
rmdir() should do likewise.
So, if this is a problem under Cygwin, it's probably better to handle it
in the rmdir() wrapper that deals with Cygwin and file descriptors.
- rm -rf calls rmdir() prior to close(), which can fail, Eric Blake, 2011/10/20
- Re: rm -rf calls rmdir() prior to close(), which can fail,
Paul Eggert <=
- Re: rm -rf calls rmdir() prior to close(), which can fail, Eric Blake, 2011/10/20
- Re: bug#9813: rm -rf calls rmdir() prior to close(), which can fail, Paul Eggert, 2011/10/20
- Re: bug#9813: rm -rf calls rmdir() prior to close(), which can fail, Eric Blake, 2011/10/20
- Re: bug#9813: rm -rf calls rmdir() prior to close(), which can fail, Eric Blake, 2011/10/20
- Re: bug#9813: rm -rf calls rmdir() prior to close(), which can fail, Paul Eggert, 2011/10/21
Re: rm -rf calls rmdir() prior to close(), which can fail, Jim Meyering, 2011/10/23