Skip to content

Commit 2e961fe

Browse files
committed
fix bootstrapped builds by opening pipe to patch stdin instead of redirecting to file (redirecting to /zip is impossible)
1 parent b132548 commit 2e961fe

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/Perl/Dist/APPerl.pm

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,12 @@ sub Build {
13091309
foreach my $srcfile ('perl.com', 'perl.com.dbg') {
13101310
my $destfile = $itemconfig->{dest};
13111311
$destfile .= '.dbg' if ($srcfile =~ /dbg$/);
1312+
if (-f $destfile) {
1313+
# avoid bus error by renaming the existing executable
1314+
my $olddest = "$destfile.old";
1315+
print "mv $destfile $olddest\n";
1316+
move($destfile, $olddest) or die "move failed: $!";
1317+
}
13121318
my @args = ("$UserProjectConfig->{apperl_output}/$CurAPPerlName/o/$srcfile", $destfile);
13131319
-e $args[0] or next;
13141320
print 'cp '.join(' ', @args)."\n";
@@ -1477,14 +1483,11 @@ sub _cmdoutput_or_die {
14771483
sub _cmdinputfile_or_die {
14781484
my $input_file = pop @_;
14791485
print join(' ', @_), " < $input_file\n";
1480-
my $kid = fork() // die "forking failed";
1481-
if ($kid == 0) {
1482-
open(STDIN, '<', $input_file) or die "Can't dup to STDIN";
1483-
exec { $_[0] } @_;
1484-
die "exec failed"
1485-
}
1486-
waitpid($kid, 0);
1487-
(($? >> 8) == 0) or die("child failed");
1486+
$SIG{PIPE} = "IGNORE";
1487+
open(my $to_kid, '|-', @_) or die "Can't fork: $!";
1488+
copy($input_file, $to_kid) or die "failed to copy $!";
1489+
close($to_kid);
1490+
(($? >> 8) == 0) or die "child failed $?";
14881491
}
14891492

14901493
sub _setup_repo {

0 commit comments

Comments
 (0)