+SKIP: {
+ require PublicInbox::SpawnPP;
+ require File::Temp;
+ my $tmp = File::Temp->newdir('spawnpp-XXXX', TMPDIR => 1);
+ my $cmd = [ qw(/bin/sh -c), 'echo $HI >foo' ];
+ my $env = [ 'HI=hihi' ];
+ my $rlim = [];
+ my $pgid = -1;
+ my $pid = PublicInbox::SpawnPP::pi_fork_exec([], '/bin/sh', $cmd, $env,
+ $rlim, "$tmp", $pgid);
+ is(waitpid($pid, 0), $pid, 'spawned process exited');
+ is($?, 0, 'no error');
+ open my $fh, '<', "$tmp/foo" or die "open: $!";
+ is(readline($fh), "hihi\n", 'env+chdir worked for SpawnPP');
+ close $fh;
+ unlink("$tmp/foo") or die "unlink: $!";
+ {
+ local $ENV{MOD_PERL} = 1;
+ $pid = PublicInbox::SpawnPP::pi_fork_exec([],
+ '/bin/sh', $cmd, $env, $rlim, "$tmp", $pgid);
+ }
+ is(waitpid($pid, 0), $pid, 'spawned process exited');
+ open $fh, '<', "$tmp/foo" or die "open: $!";
+ is(readline($fh), "hihi\n", 'env+chdir SpawnPP under (faked) MOD_PERL');
+}