in reply to Re: System call + signals = bad return code?
in thread System call + signals = bad return code?
So, working on my theory that $? and $! are being trashed because of the call to the signal handler, I localised the variables $? and $! which has made a positive difference. Here is the code.
$SIG{ALRM} = sub { local $? = 0; local $! = 0; print( "Alarm triggered in $$\n" ); unlink('/doesnt/exist'); # this will definitely fail }; alarm(2); my $rt = system("sleep 4"); print "system returned $rt, \$? is $?\n";
And the output is -
Alarm triggered in 26346 system returned 0, $? is 0
Give it a try in your code. Let me know how is goes.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: System call + signals = bad return code?
by papidave (Pilgrim) on Oct 01, 2007 at 12:41 UTC |
In Section
Seekers of Perl Wisdom