I'd like a perl job to monitor its own source and take action when those files change. I think i want to answer the following questions:

details

I have what i hope will be a long-running perl daemon that runs in conjunction with a user's X11 session. The daemon is currently is smart enough to be able to respond to a SIGHUP and re-exec itself cleanly without interrupting the user's experience.

The daemon is implemented as a (very simple) user-facing perl script in /usr/bin and a handful of specialized modules in the usual spots (e.g. /usr/share/perl5/...blah.pm on a debian system).

It's possible that the daemon itself (the script in /usr/bin and the specialized modules) will be updated while one or more instances are running. I'd like a running instance to detect when this happens, and decide (maybe prompting the user, though that's irrelevant to this question) to HUP itself.

I'd be happy to get suggestions for other ways of thinking about this problem too. FWIW, my primary concern with this tool is a GNU/Linux-based desktop environment, followed by other free software desktops. But more portable suggestions would be happily entertained.


In reply to how can i detect updates to running code? by dkg

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.