chiark / gitweb /
Work around #793471 (madness with $SIG{__WARN__} and Perl's system builtin): move...
[dgit.git] / Debian / Dgit.pm
index edb338ca455a3e9f50405a139518292a1f94931a..d66b712bc86af9ba104a88cc0bbac06e375d2370 100644 (file)
@@ -15,7 +15,8 @@ BEGIN {
 
     $VERSION     = 1.00;
     @ISA         = qw(Exporter);
-    @EXPORT      = qw(debiantag server_branch server_ref
+    @EXPORT      = qw(setup_sigwarn
+                      debiantag server_branch server_ref
                       stat_exists fail ensuredir waitstatusmsg failedcmd
                       cmdoutput cmdoutput_errok
                       git_rev_parse git_get_ref git_for_each_ref
@@ -48,6 +49,13 @@ sub FRESHREPO () { return 0x4; }
 our $debugprefix;
 our $debuglevel = 0;
 
+sub setup_sigwarn () {
+    our $sigwarn_mainprocess = $$;
+    $SIG{__WARN__} = sub { 
+       die $_[0] unless getppid == $sigwarn_mainprocess;
+    };
+}
+
 sub initdebug ($) { 
     ($debugprefix) = @_;
     open DEBUG, ">/dev/null" or die $!;