check if proc entry is a directory

This commit is contained in:
mwiegand 2022-08-11 11:24:17 +02:00
parent ac93b4f785
commit f131b368e8

View file

@ -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