[mrtg-developers] Fix for $SIG{__DIE__} handler in MRTG_lib.pm

Tobias Oetiker tobi at oetiker.ch
Thu Mar 20 11:47:44 CET 2008


Hi Steve,

neat trick with $^S ... will add ... will leave the local SIG in
anyway since I read somewhere that it is not good to have a __SIG__
handler in eval anyway ...

you may want to log a bug versus the debian packet as well to get
the fix in there too before the next debian release :-)

note that SNMP_Session 1.12 addes the localized sighanders as well
...

cheers
tobi

Today Steven Bakker wrote:

> 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
>
> _______________________________________________
> mrtg-developers mailing list
> mrtg-developers at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/mrtg-developers
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten
http://it.oetiker.ch tobi at oetiker.ch ++41 62 213 9902



More information about the mrtg-developers mailing list