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-26T09·44+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-04-26T09·44+0200
commit938092a21341b69604e9da6294fe76c13d6a1c07 (patch)
treed8b3e821ed945de09520d54226b748bd5dbeef42 /scripts/find-runtime-roots.pl.in
parent772b70952f7583cfbd6363b30f926d7ad164175c (diff)
find-runtime-roots.pl: Use Nix::Utils::readFile
Diffstat (limited to 'scripts/find-runtime-roots.pl.in')
-rwxr-xr-xscripts/find-runtime-roots.pl.in34
1 files changed, 15 insertions, 19 deletions
diff --git a/scripts/find-runtime-roots.pl.in b/scripts/find-runtime-roots.pl.in
index 64c17419ff7b..a53cefd4efb7 100755
--- a/scripts/find-runtime-roots.pl.in
+++ b/scripts/find-runtime-roots.pl.in
@@ -1,22 +1,21 @@
-#! @perl@ -w
+#! @perl@ -w @perlFlags@
 
 use strict;
-
-my $procDir = "/proc";
+use Nix::Utils;
 
 
 sub readProc {
-    return unless -d $procDir;
+    return unless -d "/proc";
+
+    opendir DIR, "/proc" or return;
 
-    opendir DIR, $procDir or return;
-    
     foreach my $name (readdir DIR) {
         next unless $name =~ /^\d+$/;
 
-        my $process = "$procDir/$name";
+        my $process = "/proc/$name";
 
         #print STDERR "=== $process\n";
-        
+
         my $target;
         print "$target\n" if $target = readlink "$process/exe";
         print "$target\n" if $target = readlink "$process/cwd";
@@ -58,18 +57,15 @@ readProc;
 lsof;
 
 
-sub readFile {
-    my $path = shift;
-    if (-e $path) {
-        if (open FILE, "$path") {
-            while (<FILE>) {
-                print;
-            }
-            close FILE;
-        }
+sub printFile {
+    my ($fn) = @_;
+    if (-e $fn) {
+        print Nix::Utils::readFile($fn), "\n";
     }
 }
 
+
 # This is rather NixOS-specific, so it probably shouldn't be here.
-readFile "/proc/sys/kernel/modprobe";
-readFile "/proc/sys/kernel/fbsplash";
+printFile "/proc/sys/kernel/modprobe";
+printFile "/proc/sys/kernel/fbsplash";
+printFile "/proc/sys/kernel/poweroff_cmd";