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 /script | |
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 'script')
-rwxr-xr-x | script/lei | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -33,6 +33,9 @@ my $exec_cmd = sub { push @rdr, shift(@old), $newfh; } my $do_exec = sub { + while (my ($io, $newfh) = splice(@rdr, 0, 2)) { + open $io, '+<&', $newfh or die "open +<&=: $!"; + } my %env = map { split(/=/, $_, 2) } splice(@argv, $argc); @ENV{keys %env} = values %env; exec(@argv); @@ -42,20 +45,17 @@ my $exec_cmd = sub { $SIG{CHLD} = $sigchld; my $pid = fork // die "fork: $!"; if ($pid == 0) { - while (my ($io, $newfh) = splice(@rdr, 0, 2)) { - open $io, '+<&', $newfh or die "open +<&=: $!"; - } - $do_exec->() if scalar(@$fds); # git-credential, pager + $do_exec->() if $fds->[1]; # git-credential, pager # parent backgrounds on MUA POSIX::setsid() > 0 or die "setsid: $!"; @parent = ($parent); return; # continue $recv_cmd in background } - if (scalar(@$fds)) { + if ($fds->[1]) { $pids{$pid} = undef; } else { - $do_exec->(); # MUA reuses all FDs + $do_exec->(); # MUA reuses stdout } }; |