aboutsummaryrefslogtreecommitdiffstats
path: root/iurt2
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2008-02-15 13:59:17 +0000
committerThierry Vignaud <tv@mandriva.org>2008-02-15 13:59:17 +0000
commit7898cad45f7616ec66b8d24eabb6d26ee56420a0 (patch)
treef81665f626f49e620c94537932168b13e516ce49 /iurt2
parent51e82cc75775386901cade70a429689beee801c5 (diff)
downloadiurt-7898cad45f7616ec66b8d24eabb6d26ee56420a0.tar
iurt-7898cad45f7616ec66b8d24eabb6d26ee56420a0.tar.gz
iurt-7898cad45f7616ec66b8d24eabb6d26ee56420a0.tar.bz2
iurt-7898cad45f7616ec66b8d24eabb6d26ee56420a0.tar.xz
iurt-7898cad45f7616ec66b8d24eabb6d26ee56420a0.zip
log on STDERR if we got SIGTERM or if an uncatched exception happenned
Diffstat (limited to 'iurt2')
-rwxr-xr-xiurt222
1 files changed, 22 insertions, 0 deletions
diff --git a/iurt2 b/iurt2
index f7e58a4..aa66a33 100755
--- a/iurt2
+++ b/iurt2
@@ -52,6 +52,28 @@ use Mkcd::Commandline qw(parseCommandLine usage);
use MDK::Common;
use Filesys::Df qw(df);
+
+sub bug_handler {
+ my ($error, $is_signal) = @_;
+
+ # exceptions in eval are OK:
+ return if $error && $^S && !$is_signal;
+
+ # we want the full backtrace:
+ $error .= "\n" if $is_signal;
+ $error .= backtrace() if $error;
+
+ warn "We got an uncatched exception:\n$error\n";
+ exit(1);
+}
+
+$SIG{SEGV} = sub { bug_handler(@_, 1) };
+$SIG{__DIE__} = \&bug_handler;
+$SIG{TERM} = sub {
+ warn "Got KILLED by SIGTERM";
+ exit(1);
+ };
+
my $program_name = 'iurt2';
my $VERSION = '0.6.2';
# sessing parameters