Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: reliable lockfiles?

by moritz (Cardinal)
on Jun 20, 2012 at 16:07 UTC ( [id://977390]=note: print w/replies, xml ) Need Help??

in reply to reliable lockfiles?

What I'd really like to achieve would be a bulletproof lockfile that can withstand this kind of situation. I remembered that File::Temp has an nice UNLINK property that forces the file to be deleted when the process exits. I'm not sure if this happens when the process is killed, however. But that's the sort of functionality that I'm looking for.

There are two approaches for deleting temp files. The first is an END block that deletes the file (but that doesn't help in the case of power outage), and the second is to call unlink while the file is still open. on UNIX systems that gives hides the file from all processes, but it remains on disc until no more file handles to it are open. Of course that's no good for locking either.

Another approach to the lock files is to put them into a location that the operating system clears out at boot time (/var/lock/ on Debian systems), or to put them on RAM discs in the first place, whose contents automatically disappear at power down/reboot.

I realize that all of that isn't exactly what you're looking for, but maybe it still gives you some ideas.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-16 23:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found