On Mon, Dec 20, 2010 at 3:34 PM, Ryan D. [email protected]
wrote:
On Dec 20, 2010, at 11:51 , Charles Oliver N. wrote:
The JVM and the JDK APIs suck at process manipulation…not JRuby.
Oh come now. If the JVM sucks at something, JRuby sucks at it too. Don’t pass
the buck.
You couldn’t be more wrong. It’s understandable since you don’t
actually know anything about JRuby’s implementation.
Notice I specifically called out the JDK APIs. The JDK provides very
primitive APIs for dealing with processes, providing no way to share
stdio streams with child processes, no way to let child processes run
without pumping their IO streams, no way to get actual PIDs and send
signals to them, and so on. These are APIs that haven’t changed in
over a decade, designed to provide the lowest common denominator of
Process management features across many platforms. They pretty much
suck.
JRuby, in its default mode, does all its process management using
these APIs. We use a few mostly-portable tricks to get real PIDs and
to make processes appear more detached than they are, but we don’t do
much more than that. However, using FFI, it’s trivial to route around
those cumbersome built-in APIs and get much more modern behavior. A
perfect example is my “spoon” gem, which uses FFI to bind the
posix_spawn syscall, which allows something no other standard JDK API
can do: sharing stdio with child processes. We also ship with a set of
native bindings (across almost a dozen platforms) to POSIX functions
that have no equivalent in the JDK, ranging from process management
(waitpid, kill), to signals, to filesystem ‘stat’, and more.
JRuby goes above and beyond the typical JVM-based language in
supporting the POSIX features in question, and the limitations of the
JVM and JDK are often not applicable to JRuby.
JRuby does the best job it can do cross-platform with the JDK APIs
provided for it. If you need to go outside those APIs, or if we “suck”
in how we utilize them, it’s a trivial matter to bind native C
process-management logic via FFI and use that. It won’t be as portable
as what we provide, but it will work.If it were trivial, why aren’t you shipping it (or at least pointing to a jruby
supported gem that does)? You’ve espoused FFI as the C-API silver bullet time and
again. I have doubts that it is that trivial as FFI itself seems non-portable.
We don’t ship anything yet because exactly one person has reported
these issues, and we provided workarounds for almost every case with
just a few lines of FFI code. I’d love to work out a complete set of
native-behaving process management APIs (for users to opt into), but
there’s only so much we can do in a given cycle. Given limited
resources, we cater to the majority first. The majority of JRuby users
do not have these issues, and would prefer we work on Ruby 1.9
compatibility, user-reported bugs, and Java integration features.
Perhaps you’d like to help? I’d happily support you.
- Charlie