* Don't use IPC::Open2, it has a subtle race bug on Mac OS X 10.4. If

the parent runs before the child, it closes some pipe file
  descriptors which causes the child to fail due to a bad file
  descriptor.  So we just use the normal open() function instead.
  
  This fixes NIX-14 (intermittent nix-pull failures).
This commit is contained in:
Eelco Dolstra 2005-09-21 17:06:06 +00:00
parent a864aca44c
commit 95304172a5

View file

@ -1,7 +1,6 @@
#! @perl@ -w -I@libexecdir@/nix #! @perl@ -w -I@libexecdir@/nix
use strict; use strict;
use IPC::Open2;
use POSIX qw(tmpnam); use POSIX qw(tmpnam);
use readmanifest; use readmanifest;
@ -74,11 +73,9 @@ print "$size store paths in manifest\n";
# Register all substitutes. # Register all substitutes.
print STDERR "registering substitutes...\n"; print STDERR "registering substitutes...\n";
my $pid = open2(\*READ, \*WRITE, "$binDir/nix-store --register-substitutes") my $pid = open(WRITE, "|$binDir/nix-store --register-substitutes")
or die "cannot run nix-store"; or die "cannot run nix-store";
close READ;
foreach my $storePath (keys %narFiles) { foreach my $storePath (keys %narFiles) {
my $narFileList = $narFiles{$storePath}; my $narFileList = $narFiles{$storePath};
foreach my $narFile (@{$narFileList}) { foreach my $narFile (@{$narFileList}) {
@ -95,7 +92,4 @@ foreach my $storePath (keys %narFiles) {
} }
} }
close WRITE; close WRITE or die "nix-store failed: $?";
waitpid $pid, 0;
$? == 0 or die "nix-store failed";