Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

systemu failing with "ArgumentError: wrong number of arguments" under JRuby #9

Closed
jchilders opened this Issue Aug 18, 2011 · 0 comments

Comments

Projects
None yet
2 participants

When running systemu under JRuby 1.6.3, all calls to systemu are failing with error:

$ irb
jruby-1.6.3 :001 > require 'systemu'
 => true
jruby-1.6.3 :002 > systemu("ruby -e 'exit 0'")
ArgumentError: wrong number of arguments (2 for 3)
        from /Users/jameschilders/.rvm/gems/jruby-1.6.3/gems/systemu-2.3.0/lib/systemu.rb:276:in `systemu'
        from /Users/jameschilders/.rvm/gems/jruby-1.6.3/gems/systemu-2.3.0/lib/systemu.rb:9:in `systemu'
        from (irb):2:in `evaluate'
        from org/jruby/RubyKernel.java:1088:in `eval'

systemu.rb:276 currently reads:

RubyProcess::RubyStatus.new_process_status(JRuby.runtime, exit_code),

Looking at the Javadocs for [RubyStats.newProcessStatus](http://www.jruby.org/apidocs/org/jruby/RubyProcess.RubyStatus.html#newProcessStatus(org.jruby.Ruby,%20long,%20long) shows that this method expects the process ID as the third and final argument. Getting the PID under Java can be tricky, but I found a (hackish) solution at Stackoverflow:

Field f = p.getClass().getDeclaredField("pid");
f.setAccessible(true);
System.out.println( f.get( p ) );

This works for UNIX-based systems, but would likely require some testing under other OSes.

@ahoward ahoward closed this in b5d60c3 Mar 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment