From: Pito Salas Date: 2009-08-25T05:36:23+09:00 Subject: Re: Asynchronous process to process pipe IO Pito Salas wrote: > Yes it does. Double-hm. > > My case is using a second ruby file, iacommand.rb, which is doing much > the same as what your -e is doing. I wonder if that makes the > difference? Or it must be something else. It does seem to be the difference between ruby -e and ./iacommand.rb. Can anyone see what the key is?? Thanks!! Here's what fails (that is, blocks) (tested both in irb and in eclipse) open("|-", "r") do |worker| if worker i = 0 worker.each_line do |line| puts "line #{i}:#{line}" i = i+1 end else exec("./iacommand.rb", "-t") end end And here's the exact text of iacommand.rb: require 'rubygems' require 'getoptlong' parser = GetoptLong.new parser.set_options( ["-h", "--help", GetoptLong::NO_ARGUMENT], ["-t", "--test", GetoptLong::NO_ARGUMENT], ["-v", "--version", GetoptLong::NO_ARGUMENT]) valid = false loop do begin opt, arg = parser.get break if not opt case opt when "-h" puts "Usage: ..." valid = true break when "-t" valid = true break when "-v" puts "Version 0.0" valid = true break end end end if valid puts "start" i = 0 5.times do puts "ballot #{i}" delay = rand(5).to_i sleep delay i = i+1 end puts "exit" else puts "invalid parameters for iacommand" end -- Posted via http://www.ruby-forum.com/.