From 65ec1f78464ce8cf4f6379aca7bbae38743c50f0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 26 Mar 2021 09:51:25 +0000 Subject: lei: support /dev/fd/[0-2] inputs and outputs in daemon Since lei-daemon won't have the same FDs as the client, we need to special-case thse mappings and won't be able to open arbitrary, non-standard FDs. We also won't attempt to support /proc/self/fd/[0-2] since that's a Linux-ism. /dev/fd/[0-2] and /dev/std{in,out,err} are portable to FreeBSD, at least. mawk(1) also supports /dev/std{out,err}, as does gawk(1) (which supports everything we can support, and arbitrary /dev/fd/$FD). --- lib/PublicInbox/LeiP2q.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/LeiP2q.pm') diff --git a/lib/PublicInbox/LeiP2q.pm b/lib/PublicInbox/LeiP2q.pm index fda055fe..25f63a10 100644 --- a/lib/PublicInbox/LeiP2q.pm +++ b/lib/PublicInbox/LeiP2q.pm @@ -107,8 +107,11 @@ sub do_p2q { # via wq_do my $in = $self->{0}; unless ($in) { my $input = $self->{input}; - if (-e $input) { - $in = $lei->fopen('<', $input) or + my $devfd = $lei->path_to_fd($input) // return; + if ($devfd >= 0) { + $in = $lei->{$devfd}; + } elsif (-e $input) { + open($in, '<', $input) or return $lei->fail("open < $input: $!"); } else { my @cmd = (qw(git format-patch --stdout -1), $input); -- cgit v1.2.3-24-ge0c7