PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed

Why can't we just change the signal disposition on system()?

 List
Subject: Why can't we just change the signal disposition on system()?
Poster: grocery_stocker
Date: 23 Mar 2007 17:50:51 -0700
Related Postings:  
This is taken from documentation:

Since "SIGINT" and "SIGQUIT" are ignored during the execution of "system", if you expect your program to terminate on receipt of these signals you will need to arrange to do so yourself based on the return value.

@args = ("command", "arg1", "arg2"); system(@args) == 0 or die "system @args failed: $?"

You can check all the failure possibilities by inspecting $? like this:

if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump \n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; }

Why can't we just trap the signal and have it exit? Ie like sub sig { exit; }

$SIG{INT} = \&sig;

Chad

 

Page2Go2.com is not responsible for content of this message.