laziness, impatience, and hubris | |
PerlMonks |
Re: How bad is $SIG{__DIE__} really?by stevieb (Canon) |
on Oct 11, 2016 at 13:47 UTC ( [id://1173726]=note: print w/replies, xml ) | Need Help?? |
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 Section
Seekers of Perl Wisdom
|
|