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

Previous Next

Package: coreutils;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Thu, 20 Oct 2011 17:41:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 9813 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eric Blake <eblake <at> redhat.com>
Cc: bug-gnulib <at> gnu.org, 9813 <at> debbugs.gnu.org
Subject: Re: bug#9813: rm -rf calls rmdir() prior to close(), which can fail
Date: Thu, 20 Oct 2011 16:46:05 -0700
On 10/20/11 12:57, Eric Blake wrote:
> That's because it's a shall fail, not a may fail error:
> 
> [EBUSY]
> The directory to be removed is currently in use by the system
> or some process and the implementation considers this to be an error.

But "in use by" does not mean "accessed by an open
file descriptor owned by".  It means that the directory
is mounted, or is the working directory of a process,
or is the root directory.  The interpretation of "in use by"
to mean "tied down by a file descriptor"
flies in the face of the plain meaning of the earlier part
of the text, which talks about what happens when one invokes
rmdir() on a directory that has an open file descriptor.

If we allow the phrase "in use by" to mean whatever the
operating system wants it to mean, then an operating system
where rmdir() always fails with errno==EBUSY would conform
to POSIX, because the O.S. could always say that the directory
is "in use by" the rmdir() call itself.  That's not what was
intended here.

> It's more than just cygwin.

So far, I've seen only Cygwin mentioned.
Where does it happen in a typical GNUish environment?

This isn't just a coreutils issue: I expect that it'll occur
many programs that do the equivalent of "rm -fr".




This bug report was last modified 13 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.