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-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 331B71F9FF for ; Mon, 8 Feb 2021 09:05:22 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 03/13] lei q: SIGWINCH process group with the terminal Date: Sun, 7 Feb 2021 23:05:11 -1000 Message-Id: <20210208090521.28909-4-e@80x24.org> In-Reply-To: <20210208090521.28909-1-e@80x24.org> References: <20210208090521.28909-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While using utime on the destination Maildir is enough for mutt to eventually notice new mail, "eventually" isn't good enough. Send a SIGWINCH to wake mutt (and likely other MUAs) immediately. This is more portable than relying on MUAs to support inotify or EVFILT_VNODE. --- resent after rebasing due to 1/13 squashes lib/PublicInbox/LEI.pm | 11 +++++++++++ lib/PublicInbox/LeiXSearch.pm | 7 ++++++- script/lei | 8 +++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index c3645698..e95a674b 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -746,6 +746,17 @@ sub start_mua { } } +sub poke_mua { # forces terminal MUAs to wake up and hopefully notice new mail + my ($self) = @_; + return unless $self->{opt}->{mua} && -t $self->{1}; + # hit the process group that started the MUA + if (my $s = $self->{sock}) { + send($s, '-WINCH', MSG_EOR); + } elsif ($self->{oneshot}) { + kill('-WINCH', $$); + } +} + # caller needs to "-t $self->{1}" to check if tty sub start_pager { my ($self) = @_; diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 588df3a4..10485220 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -317,7 +317,12 @@ Error closing $lei->{ovv}->{dst}: $! } $lei->{1} = $out; } - $l2m->lock_free ? $l2m->poke_dst : $lei->start_mua; + if ($l2m->lock_free) { + $l2m->poke_dst; + $lei->poke_mua; + } else { # mbox users + $lei->start_mua; + } } $lei->{-progress} and $lei->err('# ', $lei->{-mset_total} // 0, " matches"); diff --git a/script/lei b/script/lei index b7f21f14..0b0e2976 100755 --- a/script/lei +++ b/script/lei @@ -105,13 +105,15 @@ Falling back to (slow) one-shot mode die "recvmsg: $!"; } last if $buf eq ''; - if ($buf =~ /\Ax_it ([0-9]+)\z/) { + if ($buf =~ /\Aexec (.+)\z/) { + $exec_cmd->(\@fds, split(/\0/, $1)); + } elsif ($buf eq '-WINCH') { + kill($buf, $$); # for MUA + } elsif ($buf =~ /\Ax_it ([0-9]+)\z/) { $x_it_code = $1 + 0; last; } elsif ($buf =~ /\Achild_error ([0-9]+)\z/) { $x_it_code = $1 + 0; - } elsif ($buf =~ /\Aexec (.+)\z/) { - $exec_cmd->(\@fds, split(/\0/, $1)); } else { $sigchld->(); die $buf;