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. --- script/lei | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'script/lei') diff --git a/script/lei b/script/lei index ff4dcd45..67e8b8b0 100755 --- a/script/lei +++ b/script/lei @@ -4,8 +4,11 @@ use strict; use v5.10.1; use Socket qw(AF_UNIX SOCK_STREAM pack_sockaddr_un); +my $send_fd; if (my ($sock, $pwd) = eval { - require IO::FDPass; # will try to use a daemon to reduce load time + require PublicInbox::Spawn; + $send_fd = PublicInbox::Spawn->can('send_fd') or die + "Inline::C not installed/configured or IO::FDPass missing\n"; my $path = do { my $runtime_dir = ($ENV{XDG_RUNTIME_DIR} // '') . '/lei'; if ($runtime_dir eq '/lei') { @@ -57,7 +60,7 @@ Falling back to (slow) one-shot mode $buf .= "\0\0"; select $sock; $| = 1; # unbuffer selected $sock - IO::FDPass::send(fileno($sock), $_) for (0..2); + $send_fd->(fileno($sock), $_) for (0..2); print $sock $buf or die "print(sock, buf): $!"; while ($buf = <$sock>) { $buf =~ /\Aexit=([0-9]+)\n\z/ and exit($1 + 0); -- cgit v1.2.3-24-ge0c7