nwboy74 has asked for the wisdom of the Perl Monks concerning the following question:
After a ctrl-c is issued, the program immediately terminates. If I try to get some kind of shutdown hook implemented like below...while (1) { # get the date if ((localtime)[6] eq 4) { # do processing ... } else { sleep 86400; } }
... the signal doesn't get acted upon until the sleep statement finishes. Or perhaps there is a better way to do this.my $interrupted = 0; $SIG{INT} = sub { $interrupted = 1; &save_file; die; }; while (!$interrupted) { # get the date if ((localtime)[6] eq 4) { # do processing ... } else { sleep 86400; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SIGINT Handler
by revdiablo (Prior) on May 19, 2009 at 20:39 UTC | |
|
Re: SIGINT Handler
by targetsmart (Curate) on May 20, 2009 at 05:45 UTC |