From f131b368e858d57f100699c0b7093aa64f536d9d Mon Sep 17 00:00:00 2001 From: mwiegand Date: Thu, 11 Aug 2022 11:24:17 +0200 Subject: [PATCH] check if proc entry is a directory --- procio.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/procio.cr b/procio.cr index 54ce48b..d958bb3 100644 --- a/procio.cr +++ b/procio.cr @@ -1,9 +1,9 @@ -dir = ENV.fetch("PROCIO_DIR", "/proc") +dir = Path[ENV.fetch("PROCIO_DIR", "/proc")] result = {} of String => Array(UInt64) time = Time.local.to_s("%s%9N") Dir.entries(dir).each do |entry| - entry =~ /^\d+$/ || next + next unless (entry =~ /^\d+$/) && File.directory?(dir/entry) begin comm = File.read("#{dir}/#{entry}/comm").chomp