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(TM) Client
VM 1.6.0_23) [Windows 7-x86-java]
[INFO] OK, I'm back.
[INFO] playing with processes via system()...
[1] http://technet.microsoft.com/en-us/sysinternals/bb896645
[2] http://github.com/jonforums/measurements/blob/master/lib/tracers/processmonitor.rb
Jon
---
blog: http://jonforums.github.com/
twitter: @jonforums
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
Posted via http://www.ruby-forum.com/.
--
Posted via http://www.ruby-forum.com/.
---------------------------------------------------------------------
Thanks Roger...will give it a try...forgot about that one :(
Jon
---
blog: http://jonforums.github.com/
twitter: @jonforums
---------------------------------------------------------------------
Updated https://gist.github.com/811728 and run via jruby -Xlaunch.inproc=false system_ruby.rb but that doesn't fix things.
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(TM) 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.
I assume that's equivalent to starting it like
-J-Djruby.launch.inproc=false
?
-r
--
Posted via http://www.ruby-forum.com/.
---------------------------------------------------------------------
Tried the above snippet https://gist.github.com/811728 with 1.6.0.RC2 and 1.5.6 in both 1.8 and 1.9 modes...works on MRI Ruby and fails on JRuby as shown above.
Roger...have you tried the gist on your RC2 using the following and have it working?
jruby --1.9 -Xlaunch.inproc=false system_ruby.rb
jruby -Xlaunch.inproc=false system_ruby.rb
system("start ruby.exe -e sleep")
returns immediately in windows, but "waits" in jruby, for some reason.
I'd file a JIRA for it :)
In the meantime, ffi might help.
https://gist.github.com/280865
-r
--
Posted via http://www.ruby-forum.com/.
---------------------------------------------------------------------
I agree and will file a JIRA later this morning. Thanks for reproducing...what Windows version?
FWIW, a more relevant quick test is
jruby --1.9 -Xlaunch.inproc=false -ve "system('start dxdiag.exe')"
> In the meantime, ffi might help.
>
> https://gist.github.com/280865
Interesting, thanks for the pointer as I'm a fan of FFI. However, it's an unwelcome dependency for what I'm trying to do.
I'd rather have this Windows bug fixed in 1.6.0, or find a usable workaround.
Jon
---
blog: http://jonforums.github.com/
twitter: @jonforums
---------------------------------------------------------------------
IO.popen?
I guess ffi is bundled with jruby but not with MRI.
-r
--
Posted via http://www.ruby-forum.com/.
---------------------------------------------------------------------
> IO.popen?
Next on the to-look-at list in case this can't be resolved for 1.6.0 and as a workaround for 1.5.6.
Jon
---
blog: http://jonforums.github.com/
twitter: @jonforums
---------------------------------------------------------------------