Ruby/DL and errno

Hi,
I’m using Ruby 1.8.6 on HPUX.
When I call a unix library routine via Ruby syscall, any unix exception
correctly gets trapped.

However, when I call the same routine via Ruby/DL, the unix error
does not get trapped, and what is more, I don’t know how to retrieve
the value of unix ‘errno’.

Can anyone suggest a way around this , please ?

The demo code illustrates :

require “dl”
LIBRT=DL.dlopen("/usr/lib/librt.sl")
pmqopen=LIBRT[“mq_open”,“ISIIS”]
SYS_mq_open = 439
qname="/notHere" # non-existent queue !!
mqattr=[0,2048, 512,0].pack(“LLLL”)

puts “Using Ruby/DL :”
p pmqopen[qname, File::RDWR, 0660, mqattr]

puts “Using syscall :”
p syscall(SYS_mq_open, qname, File::RDWR, 0660, mqattr)

… produces …>>

ruby prob1demo
Using Ruby/DL :
[-1, ["/notHere", 2, 432,
“\000\000\000\000\000\000\b\000\000\000\002\000\000\000\000\000”]]
Using syscall :
prob1demo:11:in `syscall’: No such file or directory (Errno::ENOENT)
from prob1demo:11