]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon+watch: fix localization of %SIG for non-signalfd users
authorEric Wong <e@80x24.org>
Thu, 14 Jan 2021 07:06:16 +0000 (19:06 -1200)
committerEric Wong <e@80x24.org>
Thu, 14 Jan 2021 23:14:08 +0000 (23:14 +0000)
It turns out "local" did not take effect in the way we used it:
  http://nntp.perl.org/group/perl.perl5.porters/258784
  <CAHhgV8hPbcmkzWizp6Vijw921M5BOXixj4+zTh3nRS9vRBYk8w@mail.gmail.com>

Fortunately, none of the old use cases seem affected, unlike the
previous lei change to ensure consistent SIGPIPE handling.

lib/PublicInbox/Daemon.pm
script/public-inbox-watch

index 4b738b7c56c7bbc06ce8777ce2a7a63e7dbb75f5..f5543c85cee03b45845a5d0cdb806e175b7a4949 100644 (file)
@@ -514,7 +514,7 @@ EOF
                CHLD => \&reap_children,
        };
        my $sigfd = PublicInbox::Sigfd->new($sig, 0);
-       local %SIG = (%SIG, %$sig) if !$sigfd;
+       local @SIG{keys %$sig} = values(%$sig) unless $sigfd;
        PublicInbox::DS::sig_setmask($oldset) if !$sigfd;
        while (1) { # main loop
                my $n = scalar keys %pids;
@@ -628,7 +628,7 @@ sub daemon_loop ($$$$) {
                PublicInbox::Listener->new($_, $tls_cb || $post_accept)
        } @listeners;
        my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
-       local %SIG = (%SIG, %$sig) if !$sigfd;
+       local @SIG{keys %$sig} = values(%$sig) unless $sigfd;
        if (!$sigfd) {
                # wake up every second to accept signals if we don't
                # have signalfd or IO::KQueue:
index 10c7cd6f97fdfabeac71117dae93788779bbae0a..86349d71d415ba12314411f25e87b0c227018022 100755 (executable)
@@ -58,7 +58,7 @@ if ($watch) {
        PublicInbox::DS::requeue($scan) if $do_scan;
 
        my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
-       local %SIG = (%SIG, %$sig) if !$sigfd;
+       local @SIG{keys %$sig} = values(%$sig) unless $sigfd;
        if (!$sigfd) {
                PublicInbox::DS::sig_setmask($oldset);
                PublicInbox::DS->SetLoopTimeout(1000);