diff options
author | Eric Wong <e@80x24.org> | 2021-04-17 19:00:01 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-04-17 20:16:33 +0000 |
commit | e002b3bef06e9b812e95f67fcf723a1aaf632dd7 (patch) | |
tree | 0da3cc476c90ee17d015083f4c152b695fdc6692 /lib/PublicInbox/LEI.pm | |
parent | 74c0a24d49855321883f23decd687a1a866df24e (diff) | |
download | public-inbox-e002b3bef06e9b812e95f67fcf723a1aaf632dd7.tar.gz |
Since "lei q" may read queries from stdin, we must reconnect a known terminal before spawning terminal MUAs. Attempt to use stdout as stdin for this purpose, since terminal MUAs tend to expect stdout to be a terminal. Reported-By: Kyle Meyer <kyle@kyleam.com> Link: https://public-inbox.org/meta/87v98klxg3.fsf@kyleam.com/
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r-- | lib/PublicInbox/LEI.pm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index ebd0f154..f223b3de 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -840,11 +840,17 @@ sub start_mua { @cmd = map { $_ eq '%f' ? ($replaced = $mfolder) : $_ } @cmd; } push @cmd, $mfolder unless defined($replaced); - if (my $sock = $self->{sock}) { # lei(1) client process runs it - send($sock, exec_buf(\@cmd, {}), MSG_EOR); + if ($self->{sock}) { # lei(1) client process runs it + # restore terminal: echo $query | lei q -stdin --mua=... + my $io = []; + $io->[0] = $self->{1} if $self->{opt}->{stdin} && -t $self->{1}; + send_exec_cmd($self, $io, \@cmd, {}); } elsif ($self->{oneshot}) { my $pid = fork // die "fork: $!"; if ($pid > 0) { # original process + if ($self->{opt}->{stdin} && -t STDOUT) { + open STDIN, '+<&', \*STDOUT or die "dup2: $!"; + } exec(@cmd); warn "exec @cmd: $!\n"; POSIX::_exit(1); |