--00151750e244cbd5a30497f0dcfd
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Dec 18, 2010 at 8:55 PM, James Edward Gray II <james / graysoftinc.com
> wrote:

> Of course, like anything, there are tradeoffs and JRuby sucks at other
> things, like manipulating processes in a POSIX environment.  I don't use it
> in these scenarios and you know that I've filed bugs for the specific
> problems I've run into (some of those have been partially addressed).
>

For what it's worth, the APIs that Ruby provides for process management and
IPC suck and are very low level and hard to work with. It's very easy to run
into deadlocks or other issues when you try to do anything but the simplest
tasks of process creation and IPC.

As an example, take what should be a relatively easy task: spawn a process,
let it execute, and return what the process wrote to STDOUT and STDERR as
two separate strings. Simple enough, right?

Wrong. The pitfalls of attempting to do this are documented in Ara Howard's
systemu gem:

https://github.com/ahoward/systemu

There's a few options to consider to prevent deadlocks: spawning separate
threads for STDOUT and STDERR which consume data from the pipes as written,
or using some form of I/O multiplexing to test the readiness of the STDOUT
and STDERR descriptors, then consume data from whichever one is ready.

I think the best way to go here, both in general and for supporting
platforms like JRuby, is to write use case-specific libraries to handle
process management and IPC for specific tasks. systemu is one such library
(and I've added JRuby support)

-- 
Tony Arcieri
Medioh! Kudelski

--00151750e244cbd5a30497f0dcfd--