[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9813: rm -rf calls rmdir() prior to close(), which can fail

From: Paul Eggert
Subject: bug#9813: 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: 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
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 
  the dot and dot-dot entries, if present, shall be removed before rmdir() 
  and no new entries may be created in the directory, but the directory shall 
  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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]