Using Open3.capture3 fails when running with java21 from a warbler jar with
ERROR: org.jruby.embed.EvalFailedException: (EBADF) Bad file descriptor - ls
This works correctly with java 11 and warbler, or with java 21 and no warbler. This is tested on jruby 9.4.12 and warbler 2.0.5.
I simplified the Open3 code down to this repro:
out_r, out_w = IO.pipe
pid = spawn('ls', out: out_w)
wait_thr = Process.detach(pid)
out_w.close
begin
out_reader = Thread.new { out_r.read }
output = out_reader.value
puts output
ensure
out_r.close
wait_thr.join
end
When running this, it will fail at spawn. Spawning without an output pipe works fine in the java21+warbler configuration.