Module: LibC

Extended by:
FFI::Library
Defined in:
lib/scratch.rb

Class Method Summary collapse

Class Method Details

.call(err_msg = 'error in system call', &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/scratch.rb', line 16

def call(err_msg = 'error in system call', &block)
  ret = yield
  err = LibC.errno

  if ret.kind_of?(Fixnum) and ret < 0
    raise SystemCallError.new(err_msg, err)
  end
  
  ret
end