Michal Suchanek wrote:
> Removing the IO::for_fd call makes the code work in MRI but it still
> fails within few iterations on JRuby, sometimes throwing a nice null
> pointer exception.
> 
> java.lang.NullPointerException
>         at org.jruby.util.io.OpenFile.finalize(OpenFile.java:241)
>         at org.jruby.util.io.OpenFile.cleanup(OpenFile.java:226)

Ick, probably just a finalization that's happening twice or 
something...my guess would be the "descriptor" that's adopted from 
fileno is not getting ref-counted properly. Hopefully you've filed that 
in the JRuby bug tracker :)

- Charlie