Thanks to the recent input I've recieved - much appreciated.

I hope replying directly to my own node isn't considered too horribly faux pas - I'd like to clarify some things...

The transaction gig will not be a possible solution to this particular project however, so I'm stuck with doing the best I can protecting a single file that will be appended to very often by multiple processes - these processes will all be separate instances of the same program. This program, called rtmail, is a mail filter that gets piped to from sendmail.

What rtmail does is route mail to final destinations, depending upon the sender's domain. Thats easy - it's the bit where rtmail also makes a backup of all mail sent to it on the local machine using different spool files, named accordingly to each of the final remote destinations, that is the tricky part... This is mission critical stuff, and so I want to be as certain as possible that it's all being reliably and accurately backed off into these local mail spools.

One thing I didn't mention in my post, is that most of those die()'s are actually replaced with a call to an exception handler I wrote that makes certain absolutely no mail, under any circumstance is ever to simply disappear into the void.

So, what I've learned so far from your replies is that:

Perl signal traps are unreliable I really need the timeout though, so if something goes terribly wrong, I don't have a seething mass of rtmails filling the process table on the mail server, all waiting indefinately for a lock...

The race condition between the successful flock and the alarm unset is possible, but not to be worried about If that's the case, then I could simply bail on the inner eval and not ever bother with the extra checks on $@ . And when/if the race condition ever does occur, so what - it'll just get caught by my exception handler as if the flock timed out, so no actual damage or lost data will take place anyhow. But I would prefer, if possible, to not raise the exception routine if it's not truly an exception situation - perhaps I'm just being too retentive...

Thanks for everyones insight, I really appreciate the help. Beers!


In reply to RE: race condition? - flock and $SIG{ALRM} by Zarathustra
in thread race condition? - flock and $SIG{ALRM} by Zarathustra

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.