On Sat, Mar 5, 2011 at 12:07 AM, Ryan Tomayko <rtomayko / gmail.com> wrote:
> Yes. I experimented with using spoon for JRuby support in Grit some
> time ago. Unfortunately, a large number of posix_spawn() features
> require real OS file descriptors and there was no standard/supported
> way of retrieving them for most standard Java stream types.

Turns out I had some of that work laying around:

https://github.com/rtomayko/spoon/compare/spawn_file_actions

I was able to make posix_spawn_file_actions_adddup2() and
posix_spawn_file_actions_addclose() calls but running the test fails
with:

    $ ruby lib/spoon.rb
    _posix_spawn_file_actions_init => 0
    /bin/echo: write: Bad file descriptor
    read:

Under Ruby 1.9.2 with the ffi gem, I get:

    ruby lib/spoon.rb
    _posix_spawn_file_actions_init => 0
    read: hello world

If you can describe a method for retrieving real fds under JRuby
(especially IO objects returned from open() and IO.pipe()), I don't
see any reason why we couldn't have an FFI based implementation with
only a little more work.

Ryan