Created
April 20, 2018 09:58
-
-
Save Abhinickz/8cc18482a9f38c357228c8330f0f507d to your computer and use it in GitHub Desktop.
Perl sigtrap to capture signal, print and exit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use sigtrap qw(handler signal_handler normal-signals); | |
my $time = 0; | |
while(1){ | |
$time = time(); | |
print time() . "\n"; | |
sleep 1; | |
} | |
END { | |
print "CTRL+C\n"; | |
} | |
sub signal_handler | |
{ | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment