about summary refs log tree commit diff
path: root/scripts/nix-collect-garbage.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-25T14·36+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-25T14·36+0000
commit920193beb1a7b8894d100c63adadf00ad855dd64 (patch)
tree71dd2ff1a41eb376d1627cf3a2d631168b1873b2 /scripts/nix-collect-garbage.in
parenta88144215c263e62528108dfae1e781058344ef2 (diff)
* Don't continue when the call to nix fails.
Diffstat (limited to 'scripts/nix-collect-garbage.in')
-rwxr-xr-xscripts/nix-collect-garbage.in14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in
index 16a0b09f59cf..52f2743675cf 100755
--- a/scripts/nix-collect-garbage.in
+++ b/scripts/nix-collect-garbage.in
@@ -1,5 +1,8 @@
 #! /usr/bin/perl -w
 
+use strict;
+use IPC::Open2;
+
 my $linkdir = "@localstatedir@/nix/links";
 my $storedir = "@prefix@/store";
 
@@ -16,13 +19,18 @@ foreach my $arg (@ARGV) {
 
 my $extraarg = "";
 if ($keepsuccessors) { $extraarg = "--include-successors"; };
-open HASHES, "nix --query --requisites $extraarg \$(cat $linkdir/*.id) |" or die "in `nix -qrh'";
-while (<HASHES>) {
+my $pid = open2(\*READ, \*WRITE, "nix --query --requisites $extraarg \$(cat $linkdir/*.id)") 
+    or die "determining live paths";
+close WRITE;
+while (<READ>) {
 	chomp;
 	$alive{$_} = 1;
 	if ($invert) { print "$_\n"; };
 }
-close HASHES;
+close READ;
+
+waitpid $pid, 0;
+$? == 0 or die "determining live paths";
 
 exit 0 if ($invert);