From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/6] lei: stop_pager: restore stdout when done
Date: Mon, 13 Sep 2021 20:53:51 +0000 [thread overview]
Message-ID: <20210913205355.13002-3-e@80x24.org> (raw)
In-Reply-To: <20210913205355.13002-1-e@80x24.org>
The reason(s) we had for not restoring stdout haven't been valid
since script/lei (and not lei-daemon) spawns the pager, nowadays.
---
lib/PublicInbox/LEI.pm | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 6d5d3c03..784e679d 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -464,11 +464,11 @@ sub x_it ($$) {
# make sure client sees stdout before exit
$self->{1}->autoflush(1) if $self->{1};
stop_pager($self);
- if ($self->{pkt_op_p}) { # to top lei-daemon
+ if ($self->{pkt_op_p}) { # worker => lei-daemon
$self->{pkt_op_p}->pkt_do('x_it', $code);
- } elsif ($self->{sock}) { # to lei(1) client
+ } elsif ($self->{sock}) { # lei->daemon => lei(1) client
send($self->{sock}, "x_it $code", MSG_EOR);
- } elsif ($quit == \&CORE::exit) { # an admin command
+ } elsif ($quit == \&CORE::exit) { # an admin (one-shot) command
exit($code >> 8);
} # else ignore if client disconnected
}
@@ -1065,9 +1065,7 @@ sub pgr_err {
start_pager($self, { LESS => 'RX' }); # no 'F' so we prompt
print { $self->{2} } @msg;
$self->{2}->autoflush(1);
- my $pgr = delete($self->{pgr}) or return;
- $self->{2} = $pgr->[2];
- $self->{1} = $pgr->[1];
+ stop_pager($self);
send($self->{sock}, 'wait', MSG_EOR); # wait for user to quit pager
}
@@ -1075,8 +1073,8 @@ sub stop_pager {
my ($self) = @_;
my $pgr = delete($self->{pgr}) or return;
$self->{2} = $pgr->[2];
- # do not restore original stdout, just close it so we error out
close(delete($self->{1})) if $self->{1};
+ $self->{1} = $pgr->[1];
}
sub accept_dispatch { # Listener {post_accept} callback
next prev parent reply other threads:[~2021-09-13 20:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 20:53 [PATCH 0/6] a batch of misc fixes Eric Wong
2021-09-13 20:53 ` [PATCH 1/6] tests: add require_cmd, require curl when needed Eric Wong
2021-09-13 20:53 ` Eric Wong [this message]
2021-09-13 20:53 ` [PATCH 3/6] use POSIX::PIPE_BUF (instead of _POSIX_PIPE_BUF) Eric Wong
2021-09-13 20:53 ` [PATCH 4/6] lei up: localize %ENV in redispatch Eric Wong
2021-09-13 20:53 ` [PATCH 5/6] lei_xsearch: sensible errors for missing/broken externals Eric Wong
2021-09-13 20:53 ` [PATCH 6/6] lei up: fix --mua with single output 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
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=20210913205355.13002-3-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).