Module: ProcFS::ProcessExtensions::ClassMethods

Defined in:
lib/procfs/process_extensions.rb

Instance Method Summary collapse

Instance Method Details

#file_descriptors(pid = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/procfs/process_extensions.rb', line 9

def file_descriptors(pid=nil)
  pid ||= $$
  result = {}
  Dir::glob("/proc/#{$$}/fd/*").each do |fd|
    begin
      fd_id = fd.split("/").last
      result[fd_id] =  File::readlink(fd)
    rescue Errno::ENOENT
    end
  end
  result
end