Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

djberg96 (2603)

djberg96
  (email not shown publicly)

Journal of djberg96 (2603)

Tuesday December 18, 2001
04:36 PM

$SIG{__WARN__} and $SIG{__DIE__} musings

[ #1715 ]
Spent some time chatting with Ben Trott regarding interaction of his Net::SSH::Perl module and the $SIG{__DIE__} and $SIG{__WARN__} handlers.

As it stands now (i.e. version 1.23), your script will bite the dust if you try to use both his module and the signal handlers because of "eval".

I got around this by modifying 3 of his modules (RSA.pm, Cipher.pm and Auth.pm), and making 'local' copies of the signal handlers within the appropriate subroutines (making them undef). I probably just should have done it once, in the constructor, but I was led around by the debugger and once I got it working I didn't feel like going back.

Of course, after tinkering with this nonsense for a couple of hours I thought to myself, "$self, do you think that there might be a module out there that deals with this?". Naturally, I found one (only just recently written) called Sig::PackageScoped that deals with just this situation.

As it stands it could probably be handled better than just sending ssh errors to the ether (i.e. ignoring them), since I might actually want to trap those someday as well. I've suggested this idea to Ben, and he seems to like it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
    • Not a very helpful comment. Why is it considered harmful? Is it because of its interaction with 'eval'? perlvar lists this as a bug, and not one anyone seems to be too concerned with fixing. Given that more than one author uses this paradigm, I need a little more detail.
    • Ok - did you update this post? I don't remember it being a link to anything (hence my first post).

      What are your feelings on doing something like:

      *CORE::GLOBAL::die = sub{ ...handler ... }
      • I had this conversation once with Stas Bekman... Personally I think that overriding CORE::GLOBAL::die is even worse, because it probably breaks the case where some other module actually *does* use objectified exceptions. And overriding core functions should probably be done with utmost caution.

        I talked a bit about a possible solution here on perlmonks [perlmonks.org]. But it still doesn't protect you against the stupidity of others.