Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: self detecting script

by mpeters (Chaplain)
on Sep 15, 2005 at 19:57 UTC ( [id://492407]=note: print w/replies, xml ) Need Help??


in reply to Re^2: self detecting script
in thread self detecting script

Won't Perl release open file handles when it exists? Even in a die or croak when the script exists it will lose the lock.

-- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier

Replies are listed 'Best First'.
Re^4: self detecting script
by gri6507 (Deacon) on Sep 15, 2005 at 20:45 UTC
    It's not so much that the filehand is left open when the exit event happens. Usually when the lockfiles are created the script simply writes its pid to the file and closes the filehandle to flush the file. Then when the script exists, the lockfile is deleted. However, if an unexpected exit happens, then the lockfile will still be around.
      Well, if you just rely on the prescence of the lock file then you open yourself up to a race condition. If you flock it, then it's prescence after the fact doesn't really matter does it? The next run of the script will be able to grab the same lock and write it's pid there if it needs to.

      -- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier
Re^4: self detecting script
by sgifford (Prior) on Sep 15, 2005 at 21:17 UTC
    Yes. If you actually flock the file, that lock will go away when the perl process exits, though the file itself will not.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-24 17:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found