about summary refs log tree commit diff
path: root/scripts/find-runtime-roots.pl.in
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-04-26T10·06+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-04-26T10·06+0200
commit00f698eb8b93c9de50ebbadb946c5bf188e8fa98 (patch)
treefe30ae4cab0644a5561d06aecc3c53e3d7601901 /scripts/find-runtime-roots.pl.in
parent938092a21341b69604e9da6294fe76c13d6a1c07 (diff)
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.
Diffstat (limited to 'scripts/find-runtime-roots.pl.in')
-rwxr-xr-xscripts/find-runtime-roots.pl.in7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/find-runtime-roots.pl.in b/scripts/find-runtime-roots.pl.in
index a53cefd4efb7..5c2d4bed9180 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;