RolandGunslinger has asked for the wisdom of the Perl Monks concerning the following question:
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;
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.#!/perl/bin/perl -w use strict; $SIG{'INT'} = 'cleanup'; while (1) { print "."; sleep 10; } sub cleanup {die "\nending\n";}
update (broquaint): added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sleep doesn't respond to sigint(2)?
by Abigail-II (Bishop) on Oct 17, 2003 at 14:56 UTC | |
by RolandGunslinger (Curate) on Oct 17, 2003 at 15:25 UTC | |
|
Re: sleep doesn't respond to sigint(2)?
by snax (Hermit) on Oct 17, 2003 at 14:34 UTC | |
by RolandGunslinger (Curate) on Oct 17, 2003 at 14:47 UTC | |
|
Re: sleep doesn't respond to sigint(2)?
by JamesNC (Chaplain) on Oct 17, 2003 at 20:39 UTC | |
|
Re: sleep doesn't respond to sigint(2)?
by bart (Canon) on Oct 18, 2003 at 12:20 UTC | |
by JamesNC (Chaplain) on Oct 18, 2003 at 13:40 UTC |