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

Re^3: self detecting script

by mpeters (Chaplain)
on Sep 15, 2005 at 19:57 UTC ( #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
Node Status?
node history
Node Type: note [id://492407]
help
Chatterbox?
[Corion]: Meh. Some Open Source people get bought out by advertising firms to change their projects to include advertising. But nobody has approached me to buy out WWW::Mechanize ::$browser from me, to make the browsers launch an ad page ...
[Corion]: ... instead of about:blank, which the modules currently do at startup.
[Corion]: Maybe I'm too pricey. But I haven't received any offers at all ;-)
[Corion]: The ad hits from CPAN testers alone should bring in a pretty penny IMO. But maybe I misestimate the CPC that ads pay.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2017-07-24 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (354 votes). Check out past polls.