I’m trying to use system() from JRuby 1.6.0.RC1 on Windows to integrate
with Process Monitor [1] to do some WinAPI tracing for performance
comparisons. The actual code lives at [2] but I’ve got a test case that
shows the issue at figuring out MRI and JRuby's use of system() · GitHub
Basically, I want to start up procmon.exe and immediately return. Call
procmon again and tell it to wait. Fire up JRuby to run some code (line
24) to be traced by procmon and return when the test code completes.
After that’s all done, tell procmon to terminate.
Charlie has either blogged or posted to ruby-core on calling
jruby-from-jruby and, IIRC, the punchline is that JRuby does some
optimizations so that things run in the same JRuby process. The problem
I’m having is that it appears that line 24 in the gist never returns
from the system() call and I’m guessing the reason is that it was run in
the existing JRuby process.
While the MRI and JRuby behavior is different (appears to hang on JRuby)
I just want to understand JRuby’s behavior better and find a better
solution than the one I’m currently using to trace how the different
impl’s use WinAPI calls to do things like read large files line-by-line
and other things.
A working case on MRI looks like…
C:\Users\Jon\Documents\RubyDev\sandbox>ruby system_ruby.rb
[INFO] doing some work via system()…
ruby 1.9.2p174 (2011-01-28 revision 30696) [i386-mingw32]
[INFO] OK, I’m back.
[INFO] playing with processes via system()…
ruby 1.9.2p174 (2011-01-28 revision 30696) [i386-mingw32]
[INFO] OK, I’m back.
…and the failing case on JRuby looks like…
C:\Users\Jon\Documents\RubyDev\sandbox>jruby system_ruby.rb
[INFO] doing some work via system()…
jruby 1.6.0.RC1 (ruby 1.9.2 trunk 136) (2011-01-10 769f847) (Java
HotSpot™ Client
VM 1.6.0_23) [Windows 7-x86-java]
[INFO] OK, I’m back.
[INFO] playing with processes via system()…
On 1.6.0.RC1 in 1.9 mode, the issue is not where I thought it was. It’s
the first system() call with “start…” (line 23) that never returns
(MRI’s system(“start…”) does return) as this shows:
C:\Users\Jon\Documents\RubyDev\sandbox>jruby -Xlaunch.inproc=false
system_ruby.rb
[INFO] doing some work via system()…
jruby 1.6.0.RC1 (ruby 1.9.2 trunk 136) (2011-01-10 769f847) (Java
HotSpot™ Cli
VM 1.6.0_23) [Windows 7-x86-java]
[INFO] OK, I’m back from the working case.
[INFO] playing with processes via system()…
[INFO] starting 1st system
I’m checking in 1.8 mode and on 1.5.6 to see if JRuby’s
system(“start…”) behaves differently.