[OT] strange interaction between open and cwd

Nobody nobody at nowhere.com
Tue May 4 09:29:20 EDT 2010


On Tue, 04 May 2010 23:02:29 +1000, Charles wrote:

> I am by no means an expert in this area, but what I think happens (and I
> may well be wrong) is that the directory is deleted on the file system.
> The link from the parent is removed, and the parent's link count is
> decremented, as you observed, but the directory itself is still intact
> with it's original contents, including the "." and ".." names and
> associated inode numbers. Unix does not normally zero out files on
> deletion - the file's blocks usually retain their contents, and I would
> not expect directories to be a special case.

You are correct.

System calls don't "delete" inodes (files, directories, etc), they
"unlink" them. Deletion occurs when the inode's link count reaches zero
and no process holds a reference to the inode (a reference could be a
descriptor, or the process' cwd, chroot directory, or an mmap()d file, etc).

IOW, reference-counted garbage collection.




More information about the Python-list mailing list