]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spawnpp: use native perl %ENV outside of mod_perl
authorEric Wong <e@80x24.org>
Tue, 3 May 2016 06:20:54 +0000 (06:20 +0000)
committerEric Wong <e@80x24.org>
Tue, 3 May 2016 07:19:19 +0000 (07:19 +0000)
We only need to use env(1) under mod_perl; since mod_perl
is uncommon nowadays, support native %ENV for a teeny
speedup for folks uncomfortable with running vfork via
Inline::C snippet.

lib/PublicInbox/SpawnPP.pm

index dc2ef364f5b638f4b03169389ec504ab803df0fe..fe95d1269c210efb35720fd4d24584ac3eac101c 100644 (file)
@@ -19,8 +19,15 @@ sub public_inbox_fork_exec ($$$$$$) {
                if ($err != 2) {
                        dup2($err, 2) or die "dup2 failed for stderr: $!";
                }
-               exec qw(env -i), @$env, @$cmd;
-               die "exec env -i ... $cmd->[0] failed: $!\n";
+
+               if ($ENV{MOD_PERL}) {
+                       exec qw(env -i), @$env, @$cmd;
+                       die "exec env -i ... $cmd->[0] failed: $!\n";
+               } else {
+                       local %ENV = map { split(/=/, $_, 2) } @$env;
+                       exec @$cmd;
+                       die "exec $cmd->[0] failed: $!\n";
+               }
        }
        $pid;
 }