Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Question about flock and printing to file

by RichardK (Parson)
on Jun 23, 2015 at 15:23 UTC ( [id://1131657]=note: print w/replies, xml ) Need Help??


in reply to Question about flock and printing to file

As it says in the docs flock :-

locks are merely advisory

Exactly what happens will depend on the operating system you're on, what other process is trying to write to the file, and the exact timing of the writes.

IMHO flock just isn't worth using, it's almost entirely pointless.

  • Comment on Re: Question about flock and printing to file

Replies are listed 'Best First'.
Re^2: Question about flock and printing to file
by afoken (Chancellor) on Jun 23, 2015 at 16:24 UTC
    IMHO flock just isn't worth using, it's almost entirely pointless.

    flock is advisory, that's true. But to conclude that flock is useless is just wrong.

    flock won't prevent a malicious (or clueless) other process from damaging a file. But as long as all processes agree on using flock to access the file, no damage will happen. Period. Unless, of course, the file is on NFS or other network filesystems (SMB, AFS, ...). At least some versions of NFS have locking problems, other network filesystems may have them, too.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      ... as long as all processes agree on using flock to access the file, no damage will happen. Period. Unless, of course, ...

      Unfortunately, Dave, that sounds a lot like Famous Last Words.


      Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-19 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found