1 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 package PublicInbox::SpawnPP;
8 # Pure Perl implementation for folks that do not use Inline::C
9 sub public_inbox_fork_exec ($$$$$$) {
10 my ($in, $out, $err, $f, $cmd, $env) = @_;
14 dup2($in, 0) or die "dup2 failed for stdin: $!";
17 dup2($out, 1) or die "dup2 failed for stdout: $!";
20 dup2($err, 2) or die "dup2 failed for stderr: $!";
24 exec qw(env -i), @$env, @$cmd;
25 die "exec env -i ... $cmd->[0] failed: $!\n";
27 local %ENV = map { split(/=/, $_, 2) } @$env;
29 die "exec $cmd->[0] failed: $!\n";