Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] funny error msg



>>>>> "MB" == hr  <Martin> writes:

    MB> On Thu, Aug 26, 2004 at 10:45:57PM -0400, Viktor Pavlenko wrote:
    >> Sometimes simplicity of UNIX doesn't mix well with logic... If I
    >> change to /tmp/a/ in one shell and then remove it from another, the
    >> former shell, strangely enough, will not notice that the directory
    >> is gone:

    MB> of course not.
    MB> it is logical too. the same happens if you remove a file. any process
    MB> that has the file open, will not notice that it is gone.

    MB> only the entries in the directory are gone because they are removed
    MB> before the directory is removed itself.

Logical? bash runs ls(1) which will try to open(2) the directory and
read its content, _every time you run it_. strace shows that
open(2) fails:

    open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3

but ls(1) returns 0 for success anyway:

    fstat64(3, {st_mode=S_IFDIR|0755, st_size=48, ...}) = 0
    fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
    mmap2(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40212000
    getdents64(3, 0x40212038, 131072)       = -1 ENOENT (No such file or directory)
    munmap(0x40212000, 135168)              = 0
    close(3)                                = 0
    _exit(0)                                = ?

The behavior is different if the directory is not `.' (you get an
error message and 1 as return status).

Doesn't look logical to me...

-- 
Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links