Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created June 4, 2015 16:09
Show Gist options
  • Save hoelzro/66c4d2670ee447491975 to your computer and use it in GitHub Desktop.
Save hoelzro/66c4d2670ee447491975 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(say);
sub sighandler {
my ( $name ) = @_;
return sub {
open my $fh, '>', '/tmp/result';
say {$fh} "got signal $name";
close $fh;
exit 0;
};
}
$SIG{TERM} = sighandler('TERM');
$SIG{INT} = sighandler('INT');
$SIG{HUP} = sighandler('HUP');
sleep 60;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment