about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiP2q.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-03-26 09:51:25 +0000
committerEric Wong <e@80x24.org>2021-03-26 23:08:18 +0000
commit65ec1f78464ce8cf4f6379aca7bbae38743c50f0 (patch)
tree0eb594c491282fdec01b7aafc39a45485a39c287 /lib/PublicInbox/LeiP2q.pm
parentd69102cfff67e4308c560c5e8daa8f8a486ff24d (diff)
downloadpublic-inbox-65ec1f78464ce8cf4f6379aca7bbae38743c50f0.tar.gz
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).
Diffstat (limited to 'lib/PublicInbox/LeiP2q.pm')
-rw-r--r--lib/PublicInbox/LeiP2q.pm7
1 files changed, 5 insertions, 2 deletions
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);