dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 06/10] watch: ensure children can use signal handlers
Date: Sat,  2 Sep 2023 23:11:17 +0000	[thread overview]
Message-ID: <20230902231121.1821101-6-e@80x24.org> (raw)
In-Reply-To: <20230902231121.1821101-1-e@80x24.org>

Blindly using the signal set inherited from the parent process
is wrong, since the parent could've blocked all signals.  Ensure
children
---
 lib/PublicInbox/Watch.pm  | 7 +++----
 script/public-inbox-watch | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index c3b5b791..a2dc125f 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -389,7 +389,7 @@ sub watch_atfork_child ($) {
 	my $sig = delete $self->{sig};
 	$sig->{CHLD} = 'DEFAULT';
 	@SIG{keys %$sig} = values %$sig;
-	PublicInbox::DS::sig_setmask($self->{oldset});
+	PublicInbox::DS::sig_setmask(PublicInbox::DS::allowset($sig));
 }
 
 sub watch_atfork_parent ($) { _done_for_now($_[0]) }
@@ -533,8 +533,7 @@ sub watch_nntp_init ($$) {
 }
 
 sub watch { # main entry point
-	my ($self, $sig, $oldset) = @_;
-	$self->{oldset} = $oldset;
+	my ($self, $sig) = @_;
 	my $first_sig;
 	$self->{sig} //= ($first_sig = $sig);
 	my $poll = {}; # intvl_seconds => [ uri1, uri2 ]
@@ -546,7 +545,7 @@ sub watch { # main entry point
 	}
 	watch_fs_init($self) if $self->{mdre};
 	local @PublicInbox::DS::post_loop_do = (sub { !$self->quit_done });
-	PublicInbox::DS::event_loop($first_sig, $oldset); # calls ->event_step
+	PublicInbox::DS::event_loop($first_sig); # calls ->event_step
 	_done_for_now($self);
 }
 
diff --git a/script/public-inbox-watch b/script/public-inbox-watch
index 2fb27343..75a9a36b 100755
--- a/script/public-inbox-watch
+++ b/script/public-inbox-watch
@@ -17,7 +17,7 @@ my $do_scan = 1;
 GetOptions('scan!' => \$do_scan, # undocumented, testing only
 	'help|h' => \(my $show_help)) or do { print STDERR $help; exit 1 };
 if ($show_help) { print $help; exit 0 };
-my $oldset = PublicInbox::DS::block_signals();
+PublicInbox::DS::block_signals();
 STDOUT->autoflush(1);
 STDERR->autoflush(1);
 local $0 = $0; # local since this script may be eval-ed
@@ -55,5 +55,5 @@ if ($watch) {
 
 	# --no-scan is only intended for testing atm, undocumented.
 	PublicInbox::DS::requeue($scan) if $do_scan;
-	$watch->watch($sig, $oldset) while ($watch);
+	$watch->watch($sig) while ($watch);
 }

  parent reply	other threads:[~2023-09-02 23:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-02 23:11 [PATCH 01/10] ds: don't block important signals we don't use Eric Wong
2023-09-02 23:11 ` [PATCH 02/10] t/sigfd: test EVFILT_SIGNAL vs signalfd differences Eric Wong
2023-09-02 23:11 ` [PATCH 03/10] t/sigfd: better checks related to SIGWINCH Eric Wong
2023-09-02 23:11 ` [PATCH 04/10] update devel/syscall-list to devel/sysdefs-list Eric Wong
2023-09-02 23:11 ` [PATCH 05/10] daemon: workaround pre-EVFILT_SIGNAL signals Eric Wong
2023-09-02 23:11 ` Eric Wong [this message]
2023-09-02 23:11 ` [PATCH 07/10] xap_helper: support SIGTTIN+SIGTTOU worker adjustments Eric Wong
2023-09-02 23:11 ` [PATCH 08/10] xap_helper.h: include signal.h for sig* functions Eric Wong
2023-09-02 23:11 ` [PATCH 09/10] tests: add `+SCM_RIGHTS' as a require_mods target Eric Wong
2023-09-02 23:11 ` [PATCH 10/10] test_common: start_script: set default signals Eric Wong
  -- strict thread matches above, loose matches on Subject: below --
2023-09-02 11:09 [PATCH 01/10] ds: don't block important signals we don't use Eric Wong
2023-09-02 11:09 ` [PATCH 06/10] watch: ensure children can use signal handlers Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230902231121.1821101-6-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).