| 
      
      
      From: Kevin G. <ke...@go...> - 2004-06-01 17:55:39
      
     | 
| Ignoring for now the question of memory leaks
Ignorin
> Didn't my patch work with Tim's code? I added END { $? = 255 } to Tim's 
> snippet and it exited correctly with 255.
But Tim shouldn't have to add END blocks to his code.  I believe the 
problem can be summarized by this code:
------------------------
#!/usr/bin/perl
sub cleanup {
     `/bin/true`; #some shell call
}
die "arrgh";
END{cleanup()}
------------------------
If you run that like this
./test.pl && echo "program ran sucessfully"
you should *not* see the success message, because it *died*.  It looks 
to me like the $? from cleanup() is overriding the result of the die().
Tim is calling logdie() and getting a successful exit code from his 
script because deep in the guts of Mail::Mailer there's shell code 
calling the mailer program that's succeeding.  That success value seems 
to be what his script is exiting with.  Log4perl shouldn't be changing 
exit values to 'success' just because some appender has a successful 
shell function.
The test script runs as expected if you change the END block to
	END{local($?); cleanup()}
In that case, Tim's script also runs as expected, without the addition 
of an additional END block.
So we're not localzing during the GDP, we're making sure all the cleanup 
happens before the GDP.
How does that sound?  I feel like I'm not being clear, and I don't know 
why, but I do think this is the right track.
-- 
Happy Trails . . .
Kevin M. Goess
(and Anne and Frank)
904 Carmel Ave.
Albany, CA  94706
(510) 525-5217
 |