* [PATCH 2/6] lei: stop_pager: restore stdout when done
2021-09-13 20:53 6% [PATCH 0/6] a batch of misc fixes Eric Wong
@ 2021-09-13 20:53 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-09-13 20:53 UTC (permalink / raw)
To: meta
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
^ permalink raw reply related [relevance 7%]
* [PATCH 0/6] a batch of misc fixes
@ 2021-09-13 20:53 6% Eric Wong
2021-09-13 20:53 7% ` [PATCH 2/6] lei: stop_pager: restore stdout when done Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-09-13 20:53 UTC (permalink / raw)
To: meta
Eric Wong (6):
tests: add require_cmd, require curl when needed
lei: stop_pager: restore stdout when done
use POSIX::PIPE_BUF (instead of _POSIX_PIPE_BUF)
lei up: localize %ENV in redispatch
lei_xsearch: sensible errors for missing/broken externals
lei up: fix --mua with single output
lib/PublicInbox/Git.pm | 4 +---
lib/PublicInbox/LEI.pm | 12 +++++-------
lib/PublicInbox/LeiUp.pm | 26 ++++++++++++++++----------
lib/PublicInbox/LeiXSearch.pm | 5 ++++-
lib/PublicInbox/TestCommon.pm | 20 +++++++++++++-------
t/ds-leak.t | 9 +++------
t/hl_mod.t | 9 ++-------
t/httpd-corner.t | 11 ++++-------
t/imapd.t | 1 -
t/lei-daemon.t | 1 -
t/lei-externals.t | 8 ++++----
t/lei-import-http.t | 3 +--
t/lei-mirror.t | 1 +
t/lei-q-remote-import.t | 1 +
t/lei-up.t | 4 ++++
t/lei.t | 4 +---
t/nntpd.t | 7 ++-----
t/nodatacow.t | 10 ++++------
t/run.perl | 4 ++--
t/solver_git.t | 4 ++--
t/v2mirror.t | 6 ++----
t/v2reindex.t | 8 ++------
t/www_altid.t | 8 +++-----
t/www_listing.t | 8 ++------
24 files changed, 79 insertions(+), 95 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-13 20:53 6% [PATCH 0/6] a batch of misc fixes Eric Wong
2021-09-13 20:53 7% ` [PATCH 2/6] lei: stop_pager: restore stdout when done Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).