"just" spawn a new process with jruby 1.8

I’m struggling here trying to find an easy way to start an external
process in 1.8 mode (the equivalent of Process.spawn).

Anybody have any ideas here?

On Fri, Jul 16, 2010 at 11:48 AM, Roger P. [email protected]
wrote:

I’m struggling here trying to find an easy way to start an external
process in 1.8 Â mode (the equivalent of Process.spawn).

The Java process APIs spawn and give you a Process object back. We use
them inside the Ruby process-launching methods:

âž” jruby -rjava -e “puts java.lang.ProcessBuilder.new(‘ls’).start”
[email protected]

The Process object resulting (a subclass UNIXProcess in this case) has
getters for input, output, error, “wait_for”, “destroy” and so on.
Getting the actual pid out is tricky (we use such tricks internally in
JRuby).

There’s also my spoon gem:

âž” jruby -rubygems -e “require ‘spoon’; puts Spoon.spawn(‘ls’)”
2264

This uses FFI to call posix_spawn(2), launching the process in the
background and returning a pid (and additional features/uses of
posix_spawn are welcome as patches).

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Charles Nutter wrote:

On Fri, Jul 16, 2010 at 11:48 AM, Roger P. [email protected]
wrote:

I’m struggling here trying to find an easy way to start an external
process in 1.8 Â mode (the equivalent of Process.spawn).

The Java process APIs spawn and give you a Process object back. We use
them inside the Ruby process-launching methods:

âž” jruby -rjava -e “puts java.lang.ProcessBuilder.new(‘ls’).start”
[email protected]

The Process object resulting (a subclass UNIXProcess in this case) has
getters for input, output, error, “wait_for”, “destroy” and so on.
Getting the actual pid out is tricky (we use such tricks internally in
JRuby).

There’s also my spoon gem:

âž” jruby -rubygems -e “require ‘spoon’; puts Spoon.spawn(‘ls’)”
2264

This uses FFI to call posix_spawn(2), launching the process in the
background and returning a pid (and additional features/uses of
posix_spawn are welcome as patches).

Cool, thanks for the response. I was afraid we’d have to go with some
external gem or what not for this in 1.8
here’s where the ability to backport “Process.spawn” from 1.9 to 1.8
instances would be quite convenient :slight_smile:
Thanks much!
-r

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs