class Sys::Proc::Helper::LibC

System helper

Attributes

loadeds[R]

Cache for loaded shared objects

Public Class Methods

new() click to toggle source
# File lib/sys/proc/helper/lib_c.rb, line 14
def initialize
  @loadeds = {}
end

Public Instance Methods

available?(system = nil) click to toggle source

Denote if “libc“ is seen as availbale on targeted system

@return [Boolean]

# File lib/sys/proc/helper/lib_c.rb, line 43
def available?(system = nil)
  begin
    dlopen(system)
  rescue Fiddle::DLError
    return false
  rescue KeyError
    return false
  end

  loadables[system] != nil
end
dlopen(system = nil) click to toggle source

Open shared object (by system)

@param [Symbol] system @return [self]

# File lib/sys/proc/helper/lib_c.rb, line 32
def dlopen(system = nil)
  system = (system.nil? ? Sys::Proc.system : system).to_sym

  loadeds[system] ||= Fiddle.dlopen(loadables.fetch(system))

  loadeds[system]
end
loadables() click to toggle source

“libc“ shared objects identified by system

@return [Hash]

# File lib/sys/proc/helper/lib_c.rb, line 21
def loadables
  {
    linux_gnu: 'libc.so.6',
    freebsd: 'libc.so.7',
  }
end