in reply to Catching Kill Process

You set up the signal handler AFTER you've run the command. That's too late.

Perhaps the following will be of use:

{ local @SIG{'INT', 'TERM'} = (sub {warn 'Interrupt!'}) x 2; `$cmd -P ALL $interval >> $path`; } # rest of the code in the module which Creates ... files
The interrupt handler is a no-op basically. You cannot, however, set it to IGNORE. That'd also ignore the interrupt in spawned $cmd.

Replies are listed 'Best First'.
Re^2: Catching Kill Process
by Jabox (Sexton) on Jun 25, 2014 at 14:14 UTC
    { local @SIG{'INT', 'TERM'} = (sub {warn 'Interrupt!'}) x 2; `$cmd -P ALL $interval >> $path`; }

    This works the way I pictured it to, thank you! But for some reason it doesn't work for this one.

    { local @SIG{'INT', 'TERM'} = (sub {warn 'Interrupt!'}) x 2; `$cmd -P ALL $interval | timestamp.pl >> $path`; }
    Processing mpstat-5_EDT Number of samples: 9 Processing iostat-5_EDT Number of samples: 50 Processing vmstat-5_EDT Number of samples: 0

    And VM stat is the only one that runs with timestamp.pl

      Ah nevermind I found out... I placed that code inside timestamp.pl and now it finishes the way I wanted it to! :)