On Sun, Apr 10, 2011 at 11:28 PM, Urabe Shyouhei <shyouhei / ruby-lang.org> wrote:
> What C APIs are safe to use with MVM is not fully certain yet. For instance
> there are process-global states other than C global variables like current
> directory, signal masks, ... We are still exploring.

For current directory, JRuby maintains that separately and any calls
that are sensitive to cwd are modified to use this per-runtime value.
Because we share the JVM, we can't safely chdir the entire process, so
this was really the only way.

I'm not sure how MRI would do the same, since it is much more
dependent on low-level C APIs and their expectation of per-process
cwd.

~/projects/jruby  jirb
>> Dir.chdir 'src'
=> 0
>> Dir.pwd
=> "/Users/headius/projects/jruby/src"
>> require 'java'
=> true
>> mvm = org.jruby.Ruby.new_instance
=> #<Java::OrgJruby::Ruby:0x2c7ac5>
>> mvm.eval_scriptlet('Dir.pwd')
=> "/Users/headius/projects/jruby"
>> mvm.eval_scriptlet('Dir.chdir "src"')
=> 0
>> Dir.chdir '..'
=> 0
>> mvm.eval_scriptlet('Dir.pwd')
=> "/Users/headius/projects/jruby/src"
>> Dir.pwd
=> "/Users/headius/projects/jruby"
>>


- Charlie