diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2014-11-25 07:39:40 +0100 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2014-11-25 07:40:38 +0100 |
commit | 3933655d73e13c0c4f3e304d80a6da86bce5d903 (patch) | |
tree | d710b86a069f4cfae214e74732f41973de80ad82 /perl-install/drakbug.pm | |
parent | 62bda69f02ed65a1d3d1561178d799f38a5a3d5a (diff) | |
download | drakx-3933655d73e13c0c4f3e304d80a6da86bce5d903.tar drakx-3933655d73e13c0c4f3e304d80a6da86bce5d903.tar.gz drakx-3933655d73e13c0c4f3e304d80a6da86bce5d903.tar.bz2 drakx-3933655d73e13c0c4f3e304d80a6da86bce5d903.tar.xz drakx-3933655d73e13c0c4f3e304d80a6da86bce5d903.zip |
split drakbug stuff in its own module (mga#14565)
rationale: @ARGV handling in standalone breaks gurpmi --auto
Diffstat (limited to 'perl-install/drakbug.pm')
-rw-r--r-- | perl-install/drakbug.pm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/perl-install/drakbug.pm b/perl-install/drakbug.pm new file mode 100644 index 000000000..ded09d5d2 --- /dev/null +++ b/perl-install/drakbug.pm @@ -0,0 +1,45 @@ +package drakbug; + +use c; +use strict; +use common qw(backtrace if_); + + +sub bug_handler { + my ($error, $is_signal) = @_; + + # exceptions in eval are OK: + return if $error && $^S ne '0' && !$is_signal; + + # exceptions with "\n" are normal ways to quit: + if (!$is_signal && eval { $error eq MDK::Common::String::formatError($error) }) { + warn $error; + exit(255); + } + + # we want the full backtrace: + if ($is_signal) { + my $ctrace = c::C_backtrace(); + $ctrace =~ s/0:.*(\d+:[^:]*Perl_sighandler)/$1/sig; + $error .= "\nGlibc's trace:\n$ctrace\n"; + } + $error .= "Perl's trace:\n" . common::backtrace() if $error; + + my $progname = $0; + + # do not loop if drakbug crashes and do not complain about wizcancel: + if ($progname =~ /drakbug/ || $error =~ /wizcancel/ || !-x '/usr/bin/drakbug') { + warn $error; + exit(1); + } + $progname =~ s|.*/||; + exec('drakbug', if_($error, '--error', $error), '--incident', $progname); + c::_exit(1); +} + +if (!$ENV{DISABLE_DRAKBUG}) { + $SIG{SEGV} = sub { bug_handler(@_, 1) }; + $SIG{__DIE__} = \&bug_handler; +} + +1; |