add jruby support
tmm1 opened this issue · comments
Aman Gupta Karmani commented
definitely need this before 1.0
with the new cext support in 1.6, the extension actually compiles and works. we'll need to fallback to a pure jruby implementation if you try to pass fds through, but any simple usage can probably use the cext directly.
i also found a way to get exit status out of IO.popen4 on jruby: http://jira.codehaus.org/browse/JRUBY-5684
Jan Berdajs commented
My above PR should probably allow passing fds without too much extra effort.
There are a few inherent problems with native JRuby solutions that are not fully compatible with the API of posix-spawn without hacks:
- Java does not really operate on PIDs (although it is possible to obtain the PID of a java Process, but it is platform-dependant code) - spawn here returns a PID so this is a problem
- Since Java does not spawn processes based on forking, IO objects don't work in the same way (i.e. the fd => :close options have no real sense since it is not a forked process and doesn't need to close these fds - on the other hand the calling function should not close the other end of the pipe after passing it to spawn since again it is in the same process)
- I don't think it's possible to manipulate $? in a nice way, except for monkey-patching its singleton class (class << obj). It may perhaps be possible to do so by Java code, not sure. Ruby docs don't indicate any means of instantiating Process::Status.
rtomayko commented
Closing as stale for now. If JRuby is a thing someone can dedicate time too, please reopen.