Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: filesystems & Perl

by davido (Cardinal)
on Aug 12, 2016 at 20:22 UTC ( [id://1169668]=note: print w/replies, xml ) Need Help??


in reply to filesystems & Perl

"Eternity is a mere moment, just long enough for a joke." -- Hermann Hesse

It's best to look at the list of files in a directory as an approximation of reality. Unless you have a lock on a file, and everyone else is respecting the advisory lock, that file can come and go, or be altered at any time, even while you have it opened. From the moment you read the next entry via readdir to the moment you open the file, to the moment you obtain a lock, those brief moments become an eternity of computing-time during which a bad joke can be played on you.

The only certainty you have is after you've obtained a lock, and even then only if other processes are respecting the lock. If the directory can possibly change, you'll need to be tolerant of that possibility.

As for opendir and readdir in particular, I would not make critical assumptions about when they will be made aware of changes to the underlying directory's contents.


Dave

Replies are listed 'Best First'.
Re^2: filesystems & Perl
by $h4X4_|=73}{ (Monk) on Aug 13, 2016 at 08:53 UTC

    Dear Mr. Oswald,

    Great video! ++

    Thank you,
    Flex

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1169668]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-23 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found