diff options
author | Thierry Vignaud <tv@mandriva.org> | 2008-02-15 13:59:17 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mandriva.org> | 2008-02-15 13:59:17 +0000 |
commit | 7898cad45f7616ec66b8d24eabb6d26ee56420a0 (patch) | |
tree | f81665f626f49e620c94537932168b13e516ce49 /iurt2 | |
parent | 51e82cc75775386901cade70a429689beee801c5 (diff) | |
download | iurt-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-x | iurt2 | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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 |