From 0939882b8a883e3f034bd059cdec4984d36f4ac7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 3 Jan 2021 09:48:42 +0000 Subject: spawn: support send_fd+recv_fd w/o IO::FDPass IO::FDPass may be an extra installation burden I don't want to impose on users. We only support Linux and *BSDs, however. --- lib/PublicInbox/LEI.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/LEI.pm') diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 2bc4a916..6f98c934 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -25,6 +25,7 @@ use Text::Wrap qw(wrap); use File::Path qw(mkpath); use File::Spec; our $quit = \&CORE::exit; +my $recv_fd; my $GLP = Getopt::Long::Parser->new; $GLP->configure(qw(gnu_getopt no_ignore_case auto_abbrev)); my $GLP_PASS = Getopt::Long::Parser->new; @@ -615,7 +616,7 @@ sub accept_dispatch { # Listener {post_accept} callback # `say $sock' triggers "die" in lei(1) for my $i (0..2) { if (select(my $rout = $rin, undef, undef, 1)) { - my $fd = IO::FDPass::recv(fileno($sock)); + my $fd = $recv_fd->(fileno($sock)); if ($fd >= 0) { my $rdr = ($fd == 0 ? '<&=' : '>&='); if (open(my $fh, $rdr, $fd)) { @@ -671,7 +672,8 @@ sub lazy_start { my $dev_ino_expect = pack('dd', $st[0], $st[1]); # dev+ino pipe(my ($eof_r, $eof_w)) or die "pipe: $!"; my $oldset = PublicInbox::Sigfd::block_signals(); - require IO::FDPass; + $recv_fd = PublicInbox::Spawn->can('recv_fd') or die + "Inline::C not installed/configured or IO::FDPass missing\n"; require PublicInbox::Listener; require PublicInbox::EOFpipe; (-p STDOUT) or die "E: stdout must be a pipe\n"; -- cgit v1.2.3-24-ge0c7