Right. Most programs save a lock file in /var/run/X.pid where they actually save their PID. In their scripts, they first check for the existence of the file. If it doesn't exist, it is created, the PID is written to it and the file is locked and unlinked (an unlink is not able to take effect until the the last descriptor linked to that file is removed). The advantage of this is that it is much easier to find and stop a certain program without searching the process tables which are potentially very long). Also, if you start up a double of the script, it can offer optionally to kill or send any other various signal to the PID in the file as a quick form of IPC. If the process accidentally dies, the descriptor to the file is deleted, so the file can be unlinked. It's best to use such a "standard" way to manage larger apps like servers so that they cannot possibly interfere with each other.
AgentM Systems nor Nasca Enterprises nor Bone::Easy is responsible for the comments made by AgentM.

In reply to Re: Locking a script by AgentM
in thread Locking a script 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.