Skip to content

IO.popen with file mode w does not close stream and hangs on Win7 #3473

@robertpanzer

Description

@robertpanzer

This issue is related and probably the reason for asciidoctor/asciidoctorj#409

I have the following test ruby script that pipes a string to a graphviz process.
(So to retest graphviz should be installed on the machine.)
I experienced the issue with JRuby 9.0.4.0, with JRuby 1.7.+ everything works fine.

If you start this script it simply hangs:

args = ['C:\Tools\graphviz\bin\dot.exe', '-oimage.png', '-Tpng']
input = <<EOS
digraph G {
    A -> B
}
EOS

IO.popen(args, 'w') { |io|
    io.write input
}

I think the reason is that JRuby thinks that the stream is already closed in https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyIO.java#L3900 and does not close the stream.
Then the following process.waitFor() hangs until the end of days.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions