chiark / gitweb /
Infra: Exit statuses: work around bizarre behaviour of perl die wrt $?, and de-reserv...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 May 2015 13:13:25 +0000 (14:13 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 10:54:14 +0000 (11:54 +0100)
Debian/Dgit.pm
infra/dgit-repos-policy-debian

index 3f2988e4b3599f08b4b9e54fa5b2170c53d96723..e8d2608aef09a5ab3ee04b33b1025ba149830a1a 100644 (file)
@@ -36,10 +36,10 @@ our $branchprefix = 'dgit';
 
 # policy hook exit status bits
 # see dgit-repos-server head comment for documentation
 
 # policy hook exit status bits
 # see dgit-repos-server head comment for documentation
-# 1 is reserved in case something fails with `exit 1'
+# 1 is reserved in case something fails with `exit 1' and to spot
+# dynamic loader, runtime, etc., failures, which report 127 or 255
 sub NOFFCHECK () { return 0x2; }
 sub FRESHREPO () { return 0x4; }
 sub NOFFCHECK () { return 0x2; }
 sub FRESHREPO () { return 0x4; }
-# 0x80 is reserved
 
 sub debiantag ($) { 
     my ($v) = @_;
 
 sub debiantag ($) { 
     my ($v) = @_;
index 6e0f0dc3024bfbf6f80eb672f54f695b0cf9fdd2..06ad0022bd878aa4c771fc804052bc1c268a1aed 100755 (executable)
@@ -17,6 +17,8 @@ use Debian::Dgit::Policy::Debian;
 initdebug('%');
 enabledebuglevel $ENV{'DGIT_DRS_DEBUG'};
 
 initdebug('%');
 enabledebuglevel $ENV{'DGIT_DRS_DEBUG'};
 
+END { $? = 127; } # deliberate exit uses _exit
+
 our $distro = shift @ARGV // die "need DISTRO";
 our $repos = shift @ARGV // die "need DGIT-REPOS-DIR";
 our $dgitlive = shift @ARGV // die "need DGIT-LIVE-DIR";
 our $distro = shift @ARGV // die "need DISTRO";
 our $repos = shift @ARGV // die "need DGIT-REPOS-DIR";
 our $dgitlive = shift @ARGV // die "need DGIT-LIVE-DIR";
@@ -434,7 +436,7 @@ if (!$fn) {
 }
 
 my $sleepy=0;
 }
 
 my $sleepy=0;
-our $rcode = 127;
+my $rcode;
 
 for (;;) {
     poldb_setup(poldb_path($repos));
 
 for (;;) {
     poldb_setup(poldb_path($repos));
@@ -453,5 +455,6 @@ for (;;) {
     $poldbh->rollback;
 }
 
     $poldbh->rollback;
 }
 
-print STDERR $stderr;
-exit $rcode;
+print STDERR $stderr or die $!;
+flush STDERR or die $!;
+_exit $rcode;