I've written a perl script to poll the task list on a Win32 server to see if the spooler service is still up. We have had problems with the spooler service crashing, we could rebuild the box, but we're planning on moving to another server anyways, so I whipped up this script to page me when the spooler service goes down. Anyways....
The script sleeps for 10 minutes after each query to the
server. I wanted to respond more gracefully to Ctrl-C, so I decided to write up a sigint trap. To my frustration I noticed that it doesn't interrupt the sleep command. To test this concept I whipped up this;
#!/perl/bin/perl -w
use strict;
$SIG{'INT'} = 'cleanup';
while (1) {
print ".";
sleep 10;
}
sub cleanup {die "\nending\n";}
It doesn't interrupt the sleep 10 command. I looked up the docs on the sleep command, it is supposed to respond to signal interrupts like SIGALARM, but doesn't it respond to SIGINT? What would you recommend instead of the sleep command that would respond to a SIGINT and allow for a more graceful shutdown? Thanks.
update (broquaint): added formatting
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.