Ruby/DL and errno

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”
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,
Using syscall :
prob1demo:11:in `syscall’: No such file or directory (Errno::ENOENT)
from prob1demo:11

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs