our $sig; $sig = 1; $SIG{INT} = sub { $sig++; }; my $oldsig; while (1) { if ($sig != $oldsig) { $control->removeMonitorPID($monitor->{PID}); #Execute the code originally in the signal handler. $oldsig = $sig; } .... Run main loop, but make sure to poll the status of the global variable .... }