note
former33t
I first want to clarify that there are WAY better ways to do this, but if you want to increment a global variable to detect a signal being caught this will do the trick. As Paul noted earlier you shouldn't be trying to do anything complicated in the signal handler itself.
<code>
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 ....
}
</code>
612021
612055