Skip to content

Instantly share code, notes, and snippets.

@Abhinickz
Created April 20, 2018 09:58
Show Gist options
  • Save Abhinickz/8cc18482a9f38c357228c8330f0f507d to your computer and use it in GitHub Desktop.
Save Abhinickz/8cc18482a9f38c357228c8330f0f507d to your computer and use it in GitHub Desktop.
Perl sigtrap to capture signal, print and exit.
#!/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