> The following was supposedly scribed by
> Andy Adler
> on Thursday 26 February 2004 09:04 pm:
>> It looks like you can declare them as local(), and they should go back to
>> the defaults after you've left the block:
>
>Unfortunately, local doesn't help in this case. The interpreter is started
>in the 'use Inline Octave' and ends as perl quits. The user in this case
>wants to call system in the middle of this. Thus the IG{CHLD} handler
>is getting called when system returns.
It's not a matter of sequence, simply scope:
sub reap {
print "reaped\n";
die;
}
{
local($SIG{CHLD}) = \&reap;
$pid = fork();
if($pid) {
print "parent continues\n";
}
elsif(defined($pid)) {
system('sleep', 3);
}
}
system('echo', 'parent system call');
print "now parent waits\n";
waitpid($pid, WNOHANG);
So, using local() inside of your start_interpreter() block should take care of
it. The following should demonstrate it in it's barest form:
# this one dies:
sub reap {die "reaped"};
{
local($SIG{CHLD}) = \&reap;
system("ls");
}
# doesn't die:
sub reap {die "reaped"};
{
local($SIG{CHLD}) = \&reap;
}
system("ls");
--Eric