Dl/import help

Hi, (this is a re-post, in its own thread)

I'm trying to use dl/import on
ruby 1.8.2 (2004-11-06) [i686-linux]
to call setrlimit(). However I'm getting this error:

(eval):2:in `setrlimit': undefined method `[]' for nil:NilClass (NoMethodError)
        from rlimit2.rb:16

···

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/env ruby

require 'dl/import'

module LIBC
  extend DL::Importable
  dlload "libc.so"
  RLIMIT_STACK = 3
  RLIM_INFINITY = -1
  extern "int setrlimit(int, const void *)"
end

include LIBC

rlimit = [RLIM_INFINITY,RLIM_INFINITY].pack('LL').to_ptr
result = setrlimit(RLIMIT_STACK, rlimit) # this is line 16

puts result

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm using the to_ptr approach to create the structure,
described in http://www.jbrowse.com/text/rdl_en.html .

Am I doing something wrong?

Thanks,

Regards,

Bill

Seems you've hit one of the 'black holes' of ruby knowledge. It would be
good for the community to identify them and
fill them in so the next batch of new rubyists have a smoother ride...

Try it with

result = setrlimit(RLIMIT_STACK, rlimit) # this is line 16

   result = LIBC::setrlimit(RLIMIT_STACK, rlimit) # this is line 16

Guy Decoux