I'm not going to speak too much to the bad and/or the good of trapping warnings/die/interrupt with $SIG handlers, because I've used them all.

One frustrating thing though is when you are troubleshooting code when you're expecting something to happen, but then you find someone's trapped __WARN__, __DIE__ and/or INT. You've spent hours trying to figure out why something did or didn't happen to realize you were correct in the first place, but something was doing something not documented.

My advice is when you trap anything that breaks normal flow (all of these handlers affect the entire stack, even code far away), document it within your POD.

From my RPi::WiringPi distribution:

"We also trap $SIG{__DIE__} and $SIG{INT}, so that in the event of a crash, we can reset the Pi back to default settings, so components are not left in an inconsistent state."

This was needed here, as I'm dealing directly with hardware, where if the program crashes, the user needs to be assured that the hardware is reset to its original state (on the Raspberry Pi, the GPIO pins, registers and other items will stay in the state you last left them, crash or not).


In reply to Re: How bad is $SIG{__DIE__} really? by stevieb
in thread How bad is $SIG{__DIE__} really? by haukex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.