Don't know how I went so long without getting this right, be that as it may, I need to straighten my flock out.

In case you haven't already guessed I've run into the "it waits indefinitely until the lock is granted" (Perl 5.6.0 Documentation) problem.

Fumbling around with this has raised several questions.

1) Under what condition does the sleep then try lock again mechanism so popular in file locking subroutines make any sense -- if it waits forever to lock the file maybe once is enough?

2) Is there a way to make an attempt to lock a file that will time out or give up after a certain amount of time?

3) In testing to find out what was happening I've created several dozen flocking-lost scripts that seem to just hang around forever. What is there to do about this?

It's easy enough to telnet into the server and kill the pid for each (abandoned? zombie? runaway?) script. I suppose if I knew the proper terminalogy for these I could better find where this is talked about.

I suppose if I solve the problem of indefinite wait for flock the runaway scripts problem will go away. However, I'd still be interested in links to a proper discussion of that issue.

I fully expect these subjects have been well-discussed else where. But in reading the various threads I'm not seeing any discussion of what to do to prevent the script just hanging around forever.

Thanks in advance.
Claude Needham


In reply to flock -- and indefinite wait by Xxaxx

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.