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

comment on

( #3333=superdoc: 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:

use warnings; use strict; use IPC::Shareable; tie my $lock, 'IPC::Shareable', { key => 'LOCK', create => 1, exclusive => 1, destroy => 1, graceful => 1 }; $lock = $$; print "procID: $lock\n"; sleep 5;

Run it in one window:

spek@scelia ~/scratch $ perl procID: 21241 sleeps for a few seconds, during which we run it in the second window:

spek@scelia ~/repos/ipc-shareable $ perl ~/scratch/ spek@scelia ~/repos/ipc-shareable $ exited before it printed anything. After the five second sleep in proc one is done, run it in window two:

spek@scelia ~/repos/ipc-shareable $ perl ~/scratch/ procID: 21339

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 reply to Re: singleton lock not reliable by stevieb
in thread singleton lock not reliable by pidloop

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2022-08-14 10:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found