From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C3AC31F463 for ; Sun, 24 Nov 2019 00:22:40 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 09/17] daemon: use sigprocmask when respawning workers Date: Sun, 24 Nov 2019 00:22:29 +0000 Message-Id: <20191124002237.15713-10-e@80x24.org> In-Reply-To: <20191124002237.15713-1-e@80x24.org> References: <20191124002237.15713-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We need to block signals in workers during respawns until they're ready to receive signals. --- lib/PublicInbox/Daemon.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index e830a98f..90f11137 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -19,7 +19,7 @@ require PublicInbox::EvCleanup; require PublicInbox::Listener; require PublicInbox::ParentPipe; my @CMD; -my ($set_user, $oldset); +my ($set_user, $oldset, $newset); my (@cfg_listen, $stdout, $stderr, $group, $user, $pid_file, $daemonize); my $worker_processes = 1; my @listeners; @@ -77,7 +77,7 @@ sub accept_tls_opt ($) { sub daemon_prepare ($) { my ($default_listen) = @_; $oldset = POSIX::SigSet->new(); - my $newset = POSIX::SigSet->new(); + $newset = POSIX::SigSet->new(); $newset->fillset or die "fillset: $!"; sigprocmask(SIG_SETMASK, $newset, $oldset) or die "sigprocmask: $!"; @CMD = ($0, @ARGV); @@ -536,6 +536,7 @@ sub master_loop { } $n = $worker_processes; } + sigprocmask(SIG_SETMASK, $newset) or die "sigprocmask: $!"; foreach my $i ($n..($worker_processes - 1)) { my $pid = fork; if (!defined $pid) { @@ -548,6 +549,7 @@ sub master_loop { $pids{$pid} = $i; } } + sigprocmask(SIG_SETMASK, $oldset) or die "sigprocmask: $!"; # just wait on signal events here: sysread($r, my $buf, 8); }