Compare commits

...

2 commits

Author SHA1 Message Date
mwiegand
f131b368e8 check if proc entry is a directory 2022-08-11 11:24:17 +02:00
mwiegand
ac93b4f785 readme 2022-08-11 11:23:56 +02:00
2 changed files with 8 additions and 2 deletions

View file

@ -1 +1,7 @@
https://stackoverflow.com/a/63373815
# test
```
PROCIO_DIR=test crystal procio.cr
```

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