http://qs321.pair.com?node_id=300016

RolandGunslinger has asked for the wisdom of the Perl Monks concerning the following question:

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