#!/usr/bin/env perl # purpose: Loop forever, catch + report + ignore various signals # to demonstrate how to debug systemd system shutdown hangs. use strict; use warnings; sub now { my ($now) = `date +'%Y-%m-%d-%H:%M:%S'`; chop $now; return $now; } my $interrupt = 0; $SIG{TERM} = sub { $interrupt++; print now(), " SIGTERM\n"; }; $SIG{INT} = sub { $interrupt++; print now(), " SIGINT\n"; }; print now(), ' starting ', $$, ' ', $0, "\n"; while (1) { sleep(1); print now(), " interrupt running...\n" if $interrupt; }