Skip to content

Commit

Permalink
Merge pull request #3 from chorny/master
Browse files Browse the repository at this point in the history
use Win32::Job to prevent segfault in tests
  • Loading branch information
DrHyde committed Apr 26, 2015
2 parents 1e9299a + 63069a9 commit 4dfb4e3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ WriteMakefile(
'File::Temp' => 0.19,
'Capture::Tiny' => 0.05,
'Devel::CheckOS' => 1.52,
$^O eq 'MSWin32' ? ('Win32::Job' => 0,) : (),
},
dist => {
DIST_CP => 'cp',
Expand Down
42 changes: 26 additions & 16 deletions lib/CPAN/FindDependencies/MakeMaker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,33 @@ sub getreqs_from_mm {
print $MKFH $MakefilePL;
close($MKFH);

# execute, suppressing noise ...
eval { capture {
if(my $pid = fork()) { # parent
local $SIG{ALRM} = sub {
kill 9, $pid; # quit RIGHT FUCKING NOW
die("Makefile.PL didn't finish in a reasonable time\n");
};
alarm(5);
waitpid($pid, 0);
alarm(0);
} else {
exec($Config{perlpath}, 'Makefile.PL');
if ($^O eq 'MSWin32') {
require Win32::Job;
my $job = Win32::Job->new;
$job->spawn($Config{perlpath}, "perl Makefile.PL", {stdin => 'NUL', 'stdout'=>'stdout.log','stderr'=>'stderr.log'});
unless ($job->run(10)) {
chdir($cwd);
return "Makefile.PL didn't finish in a reasonable time\n";
}
} else {
# execute, suppressing noise ...
eval { capture {
if(my $pid = fork()) { # parent
local $SIG{ALRM} = sub {
kill 9, $pid; # quit RIGHT FUCKING NOW
die("Makefile.PL didn't finish in a reasonable time\n");
};
alarm(5);
waitpid($pid, 0);
alarm(0);
} else {
exec($Config{perlpath}, 'Makefile.PL');
}
} };
if($@) {
chdir($cwd);
return $@;
}
} };
if($@) {
chdir($cwd);
return $@;
}

# read Makefile
Expand Down

0 comments on commit 4dfb4e3

Please sign in to comment.