Issue Type: Bug Bug
Affects Versions: JRuby 1.7.0
Assignee: Thomas E Enebo
Components: Standard Library
Created: 09/Nov/12 10:02 AM
Description:

Where ARGV[0] is the size of the file being read in and ARGV[1] is bufsize passed to readpartial:

$ ruby foo.rb 16384 1
Starting...didn't hang!

$ ruby foo.rb 16385 1
Starting...^C

Here's foo.rb:

require 'open3'
n = ARGV[0].to_i
bufsize = ARGV[1].to_i
path = "test.txt"
File.open(path, 'w') do |f|
  f.write 'A'*n
end
STDOUT.write "Starting..."
Open3.popen3('cat', path) do |stdin, stdout, stderr|
  stdin.close
  readers = [stdout, stderr]
  while readers.any?
    ready = IO.select(readers, [], readers)
    # no writers
    # ready[1].each { ... }
    ready[0].each do |fd|
      if fd.eof?
        fd.close
        readers.delete fd
      else
        fd.readpartial bufsize
      end
    end
  end
end
puts "didn't hang!"

Works in MRI 1.8 and 1.9; hangs in both JRuby 1.8 and 1.9 mode.

Environment: * Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64
* jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on Java HotSpot(TM) 64-Bit Server VM 1.6.0_37-b06-434-10M3909 [darwin-x86_64]
* rvm 1.16.19 (stable) by Wayne E. Seguin <wayneeseg...@gmail.com>, Michal Papis <mpa...@gmail.com> [https://rvm.io/]
Project: JRuby
Labels: io open3
Priority: Major Major
Reporter: Seamus Abshere
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to