24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/rbtrace/msgq.rb', line 24
def self.recv_cmd(q, block=true)
MsgQ.rb_enable_interrupt if RUBY_VERSION > '1.9' && RUBY_VERSION < '2.0'
msg = EventMsg.new
ret = MsgQ.msgrcv(q, msg, BUF_SIZE, 0, block ? 0 : IPC_NOWAIT)
if ret == -1
if !block and [Errno::EAGAIN, Errno::ENOMSG].include?(FFI::LastError.exception)
return nil
end
FFI::LastError.raise
end
msg[:buf].to_ptr.read_string_length(BUF_SIZE)
ensure
MsgQ.rb_disable_interrupt if RUBY_VERSION > '1.9' && RUBY_VERSION < '2.0'
end
|