]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Spawn.pm
No ext_urls
[public-inbox.git] / lib / PublicInbox / Spawn.pm
index 137b80878a35bced4a0735542908190d3dce1d92..826ee508801ea1f9d519b16196c118e535997a02 100644 (file)
@@ -15,7 +15,7 @@
 # We don't want too many DSOs: https://udrepper.livejournal.com/8790.html
 
 package PublicInbox::Spawn;
-use strict;
+use v5.12;
 use parent qw(Exporter);
 use Symbol qw(gensym);
 use Fcntl qw(LOCK_EX SEEK_SET);
@@ -268,13 +268,14 @@ void recv_cmd4(PerlIO *s, SV *buf, STRLEN n)
 #endif /* defined(CMSG_SPACE) && defined(CMSG_LEN) */
 ALL_LIBC
 
-       my $inline_dir = $ENV{PERL_INLINE_DIRECTORY} //= (
+       my $inline_dir = $ENV{PERL_INLINE_DIRECTORY} // (
                        $ENV{XDG_CACHE_HOME} //
                        ( ($ENV{HOME} // '/nonexistent').'/.cache' )
                ).'/public-inbox/inline-c';
        warn "$inline_dir exists, not writable\n" if -e $inline_dir && !-w _;
        $all_libc = undef unless -d _ && -w _;
        if (defined $all_libc) {
+               local $ENV{PERL_INLINE_DIRECTORY} = $inline_dir;
                my $f = "$inline_dir/.public-inbox.lock";
                open my $oldout, '>&', \*STDOUT or die "dup(1): $!";
                open my $olderr, '>&', \*STDERR or die "dup(2): $!";
@@ -302,7 +303,9 @@ EOM
                        $all_libc = undef;
                }
        }
-       unless ($all_libc) {
+       if (defined $all_libc) { # set for Gcf2
+               $ENV{PERL_INLINE_DIRECTORY} = $inline_dir;
+       } else {
                require PublicInbox::SpawnPP;
                *pi_fork_exec = \&PublicInbox::SpawnPP::pi_fork_exec
        }
@@ -362,9 +365,9 @@ sub popen_rd {
        $opt->{1} = fileno($w);
        my $pid = spawn($cmd, $env, $opt);
        return ($r, $pid) if wantarray;
-       my $ret = gensym;
-       tie *$ret, 'PublicInbox::ProcessPipe', $pid, $r, @$opt{qw(cb arg)};
-       $ret;
+       my $s = gensym;
+       tie *$s, 'PublicInbox::ProcessPipe', $pid, $r, @{$opt->{cb_arg} // []};
+       $s;
 }
 
 sub run_die ($;$$) {