Class: Sys::Proc::Helper::LibC
- Inherits:
-
Object
- Object
- Sys::Proc::Helper::LibC
- Defined in:
- lib/sys/proc/helper/lib_c.rb
Overview
System helper
Instance Method Summary collapse
-
#available?(system = nil) ⇒ Boolean
Denote if
libc
is seen as availbale on targeted system. -
#dlopen(system = nil) ⇒ self
Open shared object (by system).
-
#initialize ⇒ LibC
constructor
A new instance of LibC.
-
#loadables ⇒ Hash
libc
shared objects identified by system.
Constructor Details
#initialize ⇒ LibC
Returns a new instance of LibC.
14 15 16 |
# File 'lib/sys/proc/helper/lib_c.rb', line 14 def initialize @loadeds = {} end |
Instance Method Details
#available?(system = nil) ⇒ Boolean
Denote if libc
is seen as availbale on targeted system
43 44 45 46 47 48 49 50 51 52 53 |
# 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) ⇒ self
Open shared object (by system)
32 33 34 35 36 37 38 |
# 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 ⇒ Hash
libc
shared objects identified by system
21 22 23 24 25 26 |
# File 'lib/sys/proc/helper/lib_c.rb', line 21 def loadables { linux_gnu: 'libc.so.6', freebsd: 'libc.so.7', } end |