![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: singleton lock not reliableby stevieb (Canon) |
on Jun 25, 2021 at 01:36 UTC ( #11134268=note: print w/replies, xml ) | Need Help?? |
First thing I thought of was shared memory. In IPC::Shareable, if one attempts to create a shared memory segment that has already been created in a separate process with exclusive set, the second process will croak(). So what I did is add a graceful flag to its options, and when set, the second process that tries to create the exclusive segment simply exits gracefully with no noise or anything. Observe: lock.pl:
Run it in one window:
...it sleeps for a few seconds, during which we run it in the second window:
...it exited before it printed anything. After the five second sleep in proc one is done, run it in window two:
So, in essence, this question prompted me to update the distribution to handle your very issue, ummm, well, gracefully. I just published it, so it may not yet be available at your mirror. Version 1.01 has the new 'graceful' feature.
In Section
Seekers of Perl Wisdom
|
|