[mrtg-developers] Fix for $SIG{__DIE__} handler in MRTG_lib.pm
Steven Bakker
steven.bakker at ams-ix.net
Thu Mar 20 10:43:43 CET 2008
Hi,
We ran into some trouble with MRTG combined with logging, where an
"eval{}" can trigger an "exit()". This is due to MRTG_lib.pm defining a
custom $SIG{__DIE__} handler, which also gets called in eval{} blocks.
Due to the way Debian packages are set up, SNMP_Session.pm is not
included in the "mrtg" package, but in a separate package
"libnsmp-session-perl". This is fine, if it weren't for the fact that it
is version 1.07, not 1.08 (which contains the fixed eval). Hence, we see
things like:
2008-03-20 01:17:02 -- Can't locate IO/Socket/INET6.pm in @INC (@INC
contains: /usr/bin/../lib/mrtg2 /usr/bin /etc/perl /usr/local/lib/perl/
5.8.4 /usr/local/share/perl/5.8.4 /usr/lib/perl5 /usr/share/perl5 /usr/
lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /usr/
share/perl5/SNMP_Session.pm line 139.
In any case, this points to a deeper problem: if any of the libraries
that MRTG pulls in does an eval{} that fails, you'll still be aborting
the program unexpectedly.
I'd suggest changing the die-handler code in MRTG_lib.pm to contain a
check for $^S (perldoc perlvar):
$SIG{__DIE__} = sub {
return if $^S;
...
};
This should also remove the need for all the localised $SIG{__DIE__}
statements.
Let me know if this makes sense.
Cheers,
Steven
More information about the mrtg-developers
mailing list