Catch __WARN__ and __DIE__, logging to file.

This commit is contained in:
Elijah Perrault committed 2011-02-03 17:12:24 -07:00
1 parent 4b7fddd218
commit 5142e4dd97
2 files changed
+28 -3

No files matched your search

+27 -3
View File
@@ -81,9 +81,11 @@ if ($BFVER[0] ne VER.".".SVER.".".REV.RSTAGE."\n") {
undef @BFVER;
# Set signal handlers.
$SIG{TERM} = \&signal_TERM;
$SIG{INT} = \&signal_INT;
$SIG{HUP} = \&signal_HUP;
$SIG{TERM} = \&signal_TERM;
$SIG{INT} = \&signal_INT;
$SIG{HUP} = \&signal_HUP;
$SIG{'__WARN__'} = \&signal_PerlWARN;
$SIG{'__DIE__'} = \&signal_PerlDIE;
API::Std::event_add("on_sigterm");
API::Std::event_add("on_sigint");
API::Std::event_add("on_sighup");
@@ -423,3 +425,25 @@ sub signal_HUP
alog "!!! Caught SIGHUP but rehash is unavailable; ignoring";
return 1;
}
# __WARN__
sub signal_PerlWARN
{
alog "Perl Warning: ".$_[0];
warn $_[0] if $DEBUG;
return 1;
}
# __DIE__
sub signal_PerlDIE
{
return if $^S;
alog "Perl Fatal: ".$_[0]." -- Terminating program!";
API::IRC::quit($_, "A fatal error occurred!") foreach (keys %SOCKET);
DB::flush();
if (-e "$Bin/auto.pid") {
system("rm $Bin/auto.pid");
}
sleep 1;
die "FATAL: ".$_[0];
}
+1
View File
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
3.0 Indev
==================================================================
* Catch __WARN__ and __DIE__, logging to file.
* Added Spanish translations.
* Added EightBall module.
* Rewrote the socket engine. This should fix random timeouts.