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

I have a small script that goes to sleep for several minutes. I trap SIGINT so that I can do a graceful shutdown of the script. The problem is, if a SIGINT is sent to the script during sleep, the script won't see it until it wakes back up.

Is there a way to wake up the script when a signal is sent to it?

Update: Yes, I should have confessed I was on windows. I rarely use signals, and I rarely use windows. I forgot that it isn't the best combination. Thanks!

Thanks,

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

Replies are listed 'Best First'.
Re: sleep and waking on signal handlers
by BrowserUk (Patriarch) on Aug 29, 2007 at 16:40 UTC
Re: sleep and waking on signal handlers
by ikegami (Patriarch) on Aug 29, 2007 at 16:09 UTC
    sleep is interrupted by signals.

      ...or are you on Windows, where signals are only partially emulated? You might have better luck with SetConsoleCtrlHandler.