dl/import help

B

Bill Kelly

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
 
L

Lyndon Samson

------=_Part_25_3818415.1127863664064
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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...

------=_Part_25_3818415.1127863664064--
 
T

ts

Try it with

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

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


Guy Decoux
 

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

Forum statistics

Threads
474,039
Messages
2,570,375
Members
47,020
Latest member
anuradha

Latest Threads

Top