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.

Reply via email to