I am attempting to minimize processor use by having a program (which I plan on spawning off as a thread) sleep for 1 hour and wake to do a check of various RSS feeds. I would like to be able to terminate this thread (either from another program or another thread from the same process) cleanly -- that is, I don't wanna just kill the process ID. Is there a way to wake a perl program that's sleeping from another thread or another program? I know it's supposed to wake up when you send it SIGALRM but the perl documentation says that some systems may use alarms for sleep and that it's dangerous. Also, is there another, cleaner, preferred method to accomplish such a task other than using sleep? I'm basically trying to write a background daemon that runs but that I can cleanly tell to exit.

In reply to Waking threads that do periodic checks by metafor

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.