G
grocery_stocker
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
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