IO.write problem on "raw" Windows

F

freeunli

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top