Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: reliable lockfiles?

by moritz (Cardinal)
on Jun 20, 2012 at 16:07 UTC ( #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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2022-11-28 21:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?