On that note, could a perl module be made to act as a dependable mutex, conditional wait variable, or semaphore using your flock method on some temp file? That would be very nice. I can't help but to wonder if your code is portable. It seems more like a trick than a solution. The original intention of flock was advisory locking which MacOS<X doesn't support (mandatory locking only which is not much better), so I wonder if this method would be of any use other than competing CGIs. Obviously, if some other program competing for the file doesn't use this exact flock, there is no synchronization solution. I can't help but wonder if the Mac's flock is implemented within MacPerl itself (since on MacOS<X, only one instance of a program may run at any given time). I think that this could be easily translated into some Mac::MoreFiles code, though.
Also, in what situation would one use your above polling loop? If you're analyzing a constantly changing file, then you would most likely rather use record locking via fcntl which, of course, brings up yet more synchronization issues. THREAD ALERT: Woah! If I were to implement muteces, etc. via your method, then I would have an excuse to recommend use Threads;. (Though conditional waits may be prohibitively expensive...or would semaphores...hmmm....*type*type*type*)
AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.

In reply to Re: Re: Re: Don't use unflock (flock 8). Ever. by AgentM
in thread flock - lordy me.... by agoth

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.