chiark / gitweb /
Detect SIGPIPE (and SIGCHLD) being blocked or ignored. Closes:#841085.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 Oct 2016 16:24:18 +0000 (17:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 Oct 2016 16:24:20 +0000 (17:24 +0100)
In fact, it seems in my test that Perl resets SIGCHLD itself, printing
something to stderr, so that trip does not actually fire.  But it
makes sense to keep it.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit

index d8827a47f3e480e0479de3543baaaec5419a36b1..203a864ce9a075091819268d411ea9b27d08c40b 100644 (file)
@@ -2,7 +2,8 @@ dgit (2.2) unstable; urgency=low
 
   * Fix config relating to Debian to actually make split brain mode
     work.  Closes:#841085.
-  * 
+  * Detect SIGPIPE (and SIGCHLD) being blocked or ignored.
+    Closes:#841085.
 
  --
 
diff --git a/dgit b/dgit
index 60ab9a6cc723e37c27742ab195dd104c2560d718..53f47136efd8c4424cfb236f006d996e31dbc491 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -5222,6 +5222,30 @@ sub parseopts () {
     }
 }
 
+sub check_env_sanity () {
+    my $blocked = new POSIX::SigSet;
+    sigprocmask SIG_UNBLOCK, $blocked, $blocked or die $!;
+
+    eval {
+       foreach my $name (qw(PIPE CHLD)) {
+           my $signame = "SIG$name";
+           my $signum = eval "POSIX::$signame" // die;
+           ($SIG{$name} // 'DEFAULT') eq 'DEFAULT' or
+               die "$signame is set to something other than SIG_DFL\n";
+           $blocked->ismember($signum) and
+               die "$signame is blocked\n";
+       }
+    };
+    return unless $@;
+    chomp $@;
+    fail <<END;
+On entry to dgit, $@
+This is a bug produced by something in in your execution environment.
+Giving up.
+END
+}
+
+
 sub finalise_opts_opts () {
     foreach my $k (keys %opts_opt_map) {
        my $om = $opts_opt_map{$k};
@@ -5257,6 +5281,7 @@ if ($ENV{$fakeeditorenv}) {
 }
 
 parseopts();
+check_env_sanity();
 git_slurp_config();
 
 print STDERR "DRY RUN ONLY\n" if $dryrun_level > 1;