sub install_handler { my ($sig, $subref) = @_; my $original = $SIG{$sig} || sub{}; $SIG{$sig} = sub { $subref->(); $original->(); } }