find-runtime-roots.pl: Search process environments for roots

For instance, this prevents paths from being deleted that are in use
by a "nix-build --run-env" session.
This commit is contained in:
Eelco Dolstra 2013-04-26 12:06:39 +02:00
parent 938092a213
commit 00f698eb8b

View file

@ -35,6 +35,13 @@ sub readProc {
}
close MAP;
}
# Get all store paths that appear in the environment of this process.
eval {
my $env = Nix::Utils::readFile "$process/environ";
my @matches = $env =~ /\/nix\/store\/[0-9a-z]+[0-9a-zA-Z\+\-\._\?=]*/g;
print "$_\n" foreach @matches;
}
}
closedir DIR;