Ruby/DL and errno

T

Tadeusz Bochan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top