Syntactic Confectionery Delight | |
PerlMonks |
Re^2: singleton lock not reliableby stevieb (Canon) |
on Jun 25, 2021 at 15:43 UTC ( [id://11134286]=note: print w/replies, xml ) | Need Help?? |
I've done one better. I've added a singleton() method. Its specifically designed to prevent more than one instance of any script (or processes that share the same shared memory segment). It's trivial to use, as it hides all of the various flags:
That's it. You can now be guaranteed that if a second instance of the script starts, it'll exit gracefully immediately as soon as singleton() is called. You can also tell it to emit a notice that the script is exiting by sending in a true value as the second 'warn' param:
If a second instance is run, the following will be thrown:
Version 1.03 has this update.
In Section
Seekers of Perl Wisdom
|
|