IO.write problem on "raw" Windows

Hi,

I have a problem with the following code:

prg = “c:\path\to\some\program” # for cmd

prg = “/cygdrive/c/path/to/some/program” # for cygwin

IO.popen(prg, “r+b”) do |pipe|
File.open ARGV[0], ‘rb’ do |fin|
pipe.write fin.read
end
end

On Windows, when running “normal” ruby from a command prompt (Windows’
cmd.exe), it blocks on write. I can interrupt it using Ctrl+C, but it
never goes through. Doing all sorts of “debug” testing, I found out
that it always blocks on the same character if the input data is the
same. Different input data (i.e. different input files, whose
filenames are given on a command line) gives different results. I am
using ruby 1.8.6.

What is even more interesting is that on Cygwin this works. I have
ruby 1.8.5 there. Also, it is working on other machines. The “other”
program itself is working fine - it’s a simple echo-clone. Do you have
any idea what might be causing this? I thought of a lot of good
reasons, but failed to find one that really is the one. At least, do
you have any suggestions of what I might try?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs