]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spawnpp: use env(1) for mod_perl compatibility
authorEric Wong <e@80x24.org>
Mon, 29 Feb 2016 01:32:24 +0000 (01:32 +0000)
committerEric Wong <e@80x24.org>
Mon, 29 Feb 2016 01:32:24 +0000 (01:32 +0000)
We cannot modify %ENV directly under mod_perl (even after forking!),
so use env(1) instead to pass the environment.

lib/PublicInbox/SpawnPP.pm

index 288625d00a9279305bea4e7de7f69fe8f493fa14..dc2ef364f5b638f4b03169389ec504ab803df0fe 100644 (file)
@@ -19,13 +19,8 @@ sub public_inbox_fork_exec ($$$$$$) {
                if ($err != 2) {
                        dup2($err, 2) or die "dup2 failed for stderr: $!";
                }
-               %ENV = ();
-               foreach my $e (@$env) {
-                       my ($k, $v) = split('=', $e, 2);
-                       $ENV{$k} = $v;
-               }
-               exec @$cmd;
-               die "exec $cmd->[0] failed: $!\n";
+               exec qw(env -i), @$env, @$cmd;
+               die "exec env -i ... $cmd->[0] failed: $!\n";
        }
        $pid;
 }