[lkml]   [1996]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: POSIX feature or Bug?

On Fri, 20 Sep 1996, Ulrich Windl wrote:
> In 2.0.20 I tried "cd /tmp; mkdir X; cd X; rmdir /tmp/X" with
> success. A subsequent "pwd" complains about the working directory...

"Don't do that then".

Actually, it's neither a bug nor a POSIX feature: it's just how things
work. Directories are just normal files, and you can think of having a
directory as your current working directory as having a file open.

What happens when you remove a file that you had open? The open file still
works, but you can't get at it though the filesystem name-space any more.
Similarly, when you remove a directory that you have as you cwd, the
directory still exists, but you can't get at it through the filesystem

There is a special restriction here, and that's the fact that a removed
directory cannot have new files created in it. That's simply because the
kernel doesn't really like the idea of having a file with a non-existent
directory as the parent..

Anyway, I think most other UNIX'es will act the same way.

[ sounds of logging onto other systems.. ]

Solaris, HP-UX and Digital UNIX work the same way as Linux, but Solaris and
HP-UX try to be "clever" and notice that you're trying to remove the cwd. But
under both the "clever" OS's you can just open another window and removing
the cwd in _another_ process, no problem (so the check seems to be just some
silly one-liner check added by some Sun/HP/xxx engineer who though the check
would be a good idea for some strange reason, but it has no real meaning).


 \ /
  Last update: 2005-03-22 13:37    [W:0.045 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site