X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=e3fc0eefd33bb6bf0372044f070cc7db03e0ad15;hp=ebeb8807b4419ded8d33237d9b09061e9a907d9a;hb=5e359c5927e8df1a0ce1652a4b83436e9d5d3410;hpb=6b0c4982c4d3aa25970e87df150162e7cd4160c1 diff --git a/dgit b/dgit index ebeb8807..e3fc0eef 100755 --- a/dgit +++ b/dgit @@ -30,6 +30,7 @@ use Dpkg::Version; use POSIX; use IPC::Open2; use Digest::SHA; +use Config; our $our_version = 'UNRELEASED'; ###substituted### @@ -133,6 +134,23 @@ END { } }; +our @signames = split / /, $Config{sig_name}; + +sub waitstatusmsg () { + if (!$?) { + return "terminated, reporting successful completion"; + } elsif (!($? & 255)) { + return "failed with error exit status ".WEXITSTATUS($?); + } elsif (WIFSIGNALED($?)) { + my $signum=WTERMSIG($?); + return "died due to fatal signal ". + ($signames[$signum] // "number $signum"). + ($? & 128 ? " (core dumped)" : ""); # POSIX(3pm) has no WCOREDUMP + } else { + return "failed with unknown wait status ".$?; + } +} + sub printdebug { print DEBUG $debugprefix, @_ or die $!; } sub fail { @@ -350,10 +368,8 @@ sub failedcmd { { local ($!); printcmd \*STDERR, "$us: failed command:", @_ or die $!; }; if ($!) { fail "failed to fork/exec: $!"; - } elsif (!($? & 0xff)) { - fail "subprocess failed with error exit status ".($?>>8); } elsif ($?) { - fail "subprocess crashed (wait status $?)"; + fail "subprocess ".waitstatusmsg(); } else { fail "subprocess produced invalid output"; } @@ -603,7 +619,7 @@ sub parsecontrolfh ($$;$) { $opts{allow_pgp}= $allowsigned || !$dpkgcontrolhash_noissigned; print STDERR Dumper(\%opts); $c = Dpkg::Control::Hash->new(%opts); - $c->parse($fh) or die "parsing of $desc failed"; + $c->parse($fh,$desc) or die "parsing of $desc failed"; last if $allowsigned; last if $dpkgcontrolhash_noissigned; my $issigned= $c->get_option('is_pgp_signed');