[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/02: cmd/lintian: Make lintian resignal itself to stop faster



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 8189ec03d735e5fc06fc6a8d48dea3b8317c7f23
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Oct 28 08:37:05 2017 +0000

    cmd/lintian: Make lintian resignal itself to stop faster
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 commands/lintian.pm | 26 +++++++++++++++++++++++---
 debian/changelog    |  6 ++++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/commands/lintian.pm b/commands/lintian.pm
index 9db64bc..58a570f 100755
--- a/commands/lintian.pm
+++ b/commands/lintian.pm
@@ -92,7 +92,7 @@ my ($experimental_output_opts, $collmap, %overrides, $unpacker, @scripts);
 my ($STATUS_FD, @CLOSE_AT_END, $PROFILE, $TAGS);
 my @certainties = qw(wild-guess possible certain);
 my (@display_level, %display_source, %suppress_tags);
-my ($action, $checks, $check_tags, $dont_check);
+my ($action, $checks, $check_tags, $dont_check, $received_signal);
 my (@unpack_info, $LAB, %unpack_options, @auto_remove);
 my $user_dirs = $ENV{'LINTIAN_ENABLE_USER_DIRS'} // 1;
 my $exit_code = 0;
@@ -742,6 +742,10 @@ sub main {
     foreach my $gname (sort $pool->get_group_names) {
         my $success = 1;
         my $group = $pool->get_group($gname);
+
+        # Do not start a new group if we have a signal pending.
+        retrigger_signal() if $received_signal;
+
         my $total_raw_res = timed_task {
             my @group_lpkg;
             my $raw_res = timed_task {
@@ -954,6 +958,8 @@ sub unpack_group {
     return
       unless $unpacker->prepare_tasks($errhandler, $group->get_processables);
 
+    retrigger_signal() if $received_signal;
+
     v_msg("Unpacking packages in group $gname");
 
     my (%timers, %hooks);
@@ -1040,6 +1046,7 @@ sub process_group {
             eval {$cs->run_check($lpkg, $group);};
             my $err = $@;
             my $raw_res = $finish_timer->($timer);
+            retrigger_signal() if $received_signal;
             if ($err) {
                 print STDERR $err;
                 print STDERR "internal error: cannot run $check check",
@@ -1779,9 +1786,22 @@ sub END {
     }
 }
 
+sub _die_in_signal_handler {
+    die("N: Interrupted.\n");
+}
+
+sub retrigger_signal {
+    # Re-kill ourselves with the same signal to ensure that the exit
+    # code reflects that we died by a signal.
+    local $SIG{$received_signal} = \&_die_in_signal_handler;
+    debug_msg(2, "Retriggering signal SIG${received_signal}");
+    return kill($received_signal, $$);
+}
+
 sub interrupted {
-    $SIG{$_[0]} = 'DEFAULT';
-    die "N: Interrupted.\n";
+    $received_signal = $_[0];
+    $SIG{$received_signal} = 'DEFAULT';
+    return _die_in_signal_handler();
 }
 
 # }}}
diff --git a/debian/changelog b/debian/changelog
index 41403a6..e3a22f9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,12 @@ lintian (2.5.57) UNRELEASED; urgency=medium
       file-contains-trailing-whitespace tag as it can include quotes
       from upstream that would be ideally left intact.
 
+  * commands/lintian.pm:
+    + [NT] Have lintian resignal between various stages of the
+      processing.  Previously, ill-timed signals would be caught and
+      "semi-ignored" with lintian happily continuing to process the
+      next package.  (Closes: #878575)
+
  -- Chris Lamb <lamby@debian.org>  Fri, 27 Oct 2017 20:00:29 +0100
 
 lintian (2.5.56) unstable; urgency=medium

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: