Re: POSIX feature or bug?

Aaron M. Ucko (amu@mit.edu)
20 Sep 1996 21:32:30 -0400


Albert Cahalan <albert@ccs.neu.edu> writes:

> The rmdir should be successful just as removing /sbin/init would be.
> The directory should actually dissappear when you change out of it.
>
> The problem I guess is that directories are nested and you could get
> many pending rmdir actions. Then there is the problem of adding files
> to a directory with a pending rmdir. You could let a rmdir of a directory
> happen even with files present, in which case the directory exists
> until all files are deleted and no process is in the directory. Then
> you get the odd result:

No you couldn't. From POSIX.2:

If any of the following conditions occur, the rmdir() function
shall return -1 and set _errno_ to the corresponding value:
...
[EEXIST] or [ENOTEMPTY]
The _path_ argument names a directory that is not an empty
directory. (5.5.2.4)

The spec is ambiguous on the original issue, BTW:
If the named directory is the root directory or the current
working directory of any process, it is unspecified whether
the function succeeds or whether it fails and sets _errno_ to
[EBUSY]. (5.5.2.2)

-- 
Aaron M. Ucko (amu@mit.edu) | Geek Code 3.12 [for explanation, please see
http://krypton.mankato.msus.edu/~hayden/geek.html]: GCS/M/S/C d- s+: a18
C++(+++)>++++ UL++>++++S+I+ P++(+++) L+++(++++)>+++++ E+ W+ N++(+) o+ K- 
w--- O M-@ V-(--) PS++(+++) PE- Y+ PGP(+) t(+) !5 X-- R(-) tv-@ b++(+++) DI+
D-- G++(+++) e>+++++(*) h!>+ r-(--)>+++ y? | "That's right," he said. "We're
philosophers.  We think, therefore we am." -- Terry Pratchett, _Small Gods_