]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Spawn.pm
viewvcs: prepopulate search bar with dfpost + dfn
[public-inbox.git] / lib / PublicInbox / Spawn.pm
index 3f69108a094d3dc1e61aa667927edbdf232ec7f9..826ee508801ea1f9d519b16196c118e535997a02 100644 (file)
@@ -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 ($;$$) {