If all programs are going to read or write the log, then there is no need for the lockfile. Everything can flock the log directly.

There are two good reasons to use a lockfile. The first is that you may have operations involving multiple data sources and you want to maintain sync. The second is that you are both reading and writing to the same file and you want to avoid race conditions due to dropping the lock. But if everything is either just reading or just writing, then there is no race to worry about.

Also one warning on lockfiles. If you want to get atomic behaviour (if you don't know what that is then let your eyes glaze over and say "Yes") then you do not want to delete the lockfile. Else 2 processes can go to create it at once, one creates, the other overwrites with its new, both have filehandles to different files. (One is temporary.) The flocks both are captured at once, both think they have the lock. The timing has to be reasonably precise to do this, but it is worth knowing about.


In reply to Re (tilly) 2: CGI Form processing by tilly
in thread CGI Form processing by Anonymous Monk

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.