unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/4] cindex: leave SIGTSTP and SIGCONT unblocked
Date: Tue, 28 Mar 2023 02:59:04 +0000	[thread overview]
Message-ID: <20230328025904.3822761-5-e@80x24.org> (raw)
In-Reply-To: <20230328025904.3822761-1-e@80x24.org>

This makes it easier to pause and restart long-running indexing
jobs which use our event loop.
---
 lib/PublicInbox/CodeSearchIdx.pm | 3 ++-
 lib/PublicInbox/DS.pm            | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index f60af015..8d57ec10 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -841,7 +841,8 @@ sub cidx_run { # main entry point
 	my ($self) = @_;
 	my $restore_umask = prep_umask($self);
 	local $DEFER = [];
-	local $SIGSET = PublicInbox::DS::block_signals();
+	local $SIGSET = PublicInbox::DS::block_signals(
+					POSIX::SIGTSTP, POSIX::SIGCONT);
 	my $restore = PublicInbox::OnDestroy->new($$,
 		\&PublicInbox::DS::sig_setmask, $SIGSET);
 	local $LIVE = {};
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 340086fc..98084b5c 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -193,10 +193,11 @@ sub RunTimers {
 
 sub sig_setmask { sigprocmask(SIG_SETMASK, @_) or die "sigprocmask: $!" }
 
-sub block_signals () {
-	my $oldset = POSIX::SigSet->new;
+sub block_signals { # anything in @_ stays unblocked
 	my $newset = POSIX::SigSet->new;
 	$newset->fillset or die "fillset: $!";
+	$newset->delset($_) for @_;
+	my $oldset = POSIX::SigSet->new;
 	sig_setmask($newset, $oldset);
 	$oldset;
 }

      parent reply	other threads:[~2023-03-28  2:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28  2:59 [PATCH 0/4] cindex updates Eric Wong
2023-03-28  2:59 ` [PATCH 1/4] cindex: simplify some internal data structures Eric Wong
2023-03-28  2:59 ` [PATCH 2/4] cindex: always break out of event loop on $DO_QUIT Eric Wong
2023-03-28  2:59 ` [PATCH 3/4] cindex: interleave prune with indexing Eric Wong
2023-03-29 20:32   ` [PATCH v2] " Eric Wong
2023-03-28  2:59 ` Eric Wong [this message]

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

  List information: https://public-inbox.org/README

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

  git send-email \
    --in-reply-to=20230328025904.3822761-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.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).