Forum: JRuby killing jruby...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Arnaud G. (Guest)
on 2009-02-20 13:06
(Received via mailing list)
Hello,

When I use exec "jruby my_update_prog.rb" or "java -jar jruby-complete
my_update_prog.rb" from another jruby program the java "parent"
process is not kill until the end of the second  ( I dit my test on my
vista computer)...
It is a big problem since the first java process hold the files, and
my second program cannot delete it...

I thought that using exec kill the current java process....
(I also noticed that using exec "jruby prog.r" do not create another
java process whereas using exec "java ..." create another..., what is
weard is that the first java process wait the end of the second to die
??)

How to solve this problem...


thanks

arnaud

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Nick S. (Guest)
on 2009-02-20 16:47
(Received via mailing list)
On Fri, Feb 20, 2009 at 5:06 AM, Arnaud G. 
<removed_email_address@domain.invalid>
wrote:
> (I also noticed that using exec "jruby prog.r" do not create another
> java process whereas using exec "java ..." create another..., what is
> weard is that the first java process wait the end of the second to die
> ??)
>
> How to solve this problem...

I'm not sure there's a straightforward answer to this problem. #exec
is one of the corner cases for JRuby where, due to the restrictions of
the JVM, we cannot emulate the behavior of MatzRuby. We have similar
problems with #fork and thus popular gems like daemonize don't
currently function.

I'm afraid I don't have any suggestion other than reworking your code
around this restriction. Maybe someone else has ideas.

/Nick

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2009-02-20 18:13
(Received via mailing list)
Arnaud G. wrote:
> Hello,
>
> When I use exec "jruby my_update_prog.rb" or "java -jar jruby-complete
> my_update_prog.rb" from another jruby program the java "parent"
> process is not kill until the end of the second  ( I dit my test on my
> vista computer)...
> It is a big problem since the first java process hold the files, and
> my second program cannot delete it...

Because we can't simply exec to replace the current process (does exec
even do that on windows?) we simulate that behavior by waiting for the
subprocess to die and then quickly bailing out of the parent process. I
think we're open to suggestions here on how to improve that.

> I thought that using exec kill the current java process....
> (I also noticed that using exec "jruby prog.r" do not create another
> java process whereas using exec "java ..." create another..., what is
> weard is that the first java process wait the end of the second to die
> ??)

Because a lot of Ruby scripts launch subprocesses, and because JRuby
takes a bit more time to startup than C Ruby, at one point we added
behavior to allow running some of those subprocesses in the same JVM.
Basically, we detect if you're calling "jruby" or "ruby" in the parent
process and just spin up another jruby instance in the same JVM.

You can disable this behavior by passing -J-Djruby.launch.inproc=true at
jruby command line. Maybe that will help you?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.