>>> On 2/13/2008 at 5:15 PM, in message <3641.1202944529 at skuld.wookimus.net>, Chad
Walstrom <chewie at wookimus.net> wrote:
> O.K.  I'm tired of writing BASH scripts.  I've decided to jump wholesale
> into Perl as any good Systems Engineer should, right?  I'm running into
> a bit of a problem: signal handling.
> Let's say I want to run system application SYSAPP_A once for each
> element in LIST_A, and if that were to fail, run SYSAPP_B for that
> element.  If I don't trap for signals, and I try to interrupt the Perl
> script with CTRL-C (SIGINT), it kills either SYSAPP_A or SYSAPP_B and
> then continues on looping over LIST_A elements.
> What I want is for the Perl script to die unconditionally.  So, I try this:
>      $SIG{INT} = sub { die "Um, I'm outta here!\n"; };
> This kind of works, but if I hit CTRL-C during SYSAPP_A's run, it fails
> and SYSAPP_B tries to execute.  SYSAPP_A and SYSAPP_B are each called
> with the "system" built-in.
> What do I need to do to make sure the script dies unconditionally when
> any child also receives an interrupt?

Chad,

Check the return value of 'system' and 'die' if it is not zero, if that works. 

If that won't work for you, you could check the output of commands by 
using backticks ($value = `SYSAPP_A`;) instead of using 'system'.

Maybe you can use $SIG{CHLD} for something?

Use 'perldoc perlvar', 'perldoc perlipc', 'perldoc -f system', 
'perldoc -f die', and especially 'perldoc perldoc' to your advantage.

Best of luck,

Troy