From 00f698eb8b93c9de50ebbadb946c5bf188e8fa98 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 26 Apr 2013 12:06:39 +0200 Subject: [PATCH] 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. --- scripts/find-runtime-roots.pl.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/find-runtime-roots.pl.in b/scripts/find-runtime-roots.pl.in index a53cefd4ef..5c2d4bed91 100755 --- a/scripts/find-runtime-roots.pl.in +++ b/scripts/find-runtime-roots.pl.in @@ -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;