Oh wisest Monks,

Is there a way to awake from the eternal sleep()? Two processes exist, a child doing the work and a parent checking that the other is still running. The parent ping()s the SOAP server the child is running, then sleep()s for N seconds. If the child dies just after the parent ping()s, then the process may be down for as much as N-1 seconds. The catch here is that the child is stopping on purpose, to replace a configuration file. This is an advantage, but I do not know exactly how to take advantage of it.

Be it that the child stops itself, the parent can receive a signal from the child to stop what it's doing, sleep()ing. However, I've read over and over that one should limit what's done in a signal handler.

So, the child signals the parent, then stops. The parent catchs the signal, and restarts the child. Before the parent can leave the signal handler, it will need to test the child (via SOAP) to ensure the child starts with the new configuration file, else replace the file and restart again.

1) Is this too much to do inside the singal handler?
2) If 1) is 'yes', is there a way to leave the signal handler, break from the sleep(), and then attempt to restart the child, test, etc?
3) Is there a better way than a signal to telling the sleep()ing parent that the child is stopping?

On a side note: Another solution is to shorten the sleep time of the parent. The problem here is that the parent process then has a larger system footprint (i.e. processor usage).

Thank you once again, Casey


In reply to Awake from sleep() by cmilfo

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.