Skip to content

Open3::capture2 and friends hang on stdin_data on Java GTE 9 #5642

@yaauie

Description

@yaauie

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc):
    jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 9.0.4+11 on 9.0.4+11 +jit [darwin-x86_64]
    
    and
    jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 11.0.1+13-LTS on 11.0.1+13-LTS +jit [darwin-x86_64]
    
  • Operating system and platform (e.g. uname -a):
    Darwin castrovel.local 16.7.0 Darwin Kernel Version 16.7.0: Sun Oct 28 22:30:19 PDT 2018; root:xnu-3789.73.27~1/RELEASE_X86_64 x86_64
    

Other relevant info you may wish to add:

  • Installed or activated gems: N/A
  • Application/framework version (e.g. Rails, Sinatra): N/A
  • Environment variables: N/A

Expected Behavior

  • When Open::capture2() (and friends) is given stdin_data: 'hello, world', the supplied string should be provided as stdin to the shelled out command
#!/usr/bin/env ruby
require 'open3'
$stderr.puts(RUBY_DESCRIPTION)
capture, status = Open3.capture2('cat', stdin_data: 'hello, world')
$stdout.puts(capture: capture, status: status)

-- cat.rb

With Java 8:

╭─{ yaauie@castrovel:~/src/yaauie/jruby-vs-java-11 }
╰─○ JAVA_HOME="$(/usr/libexec/java_home -v 1.8)" ruby cat.rb
jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 25.152-b16 on 1.8.0_152-b16 +jit [darwin-x86_64]
{:capture=>"hello, world", :status=>#<Process::Status: pid 18214 exit 0>}
[success]

Actual Behavior

With Java 9+

╭─{ yaauie@castrovel:~/src/yaauie/jruby-vs-java-11 }
╰─○ JAVA_HOME="$(/usr/libexec/java_home -v 9)" ruby cat.rb
jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 9.0.4+11 on 9.0.4+11 +jit [darwin-x86_64]

The command hangs at this point; when it is sent SIGINT, it resumes without having sent the string as stdin to the child process:

^C{:capture=>"", :status=>#<Process::Status: pid 18296 INT (signal 2)>}
[error: 130 (15.000s)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions