Project

General

Profile

Bug #3215

Windows: IO.popen returns "handle is invalid"

Added by docwhat (Christian Höltje) over 10 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
ruby -v:
ruby 1.9.1p376 (2009-12-07) [x64-mswin64_80]
[ruby-core:29845]

Description

=begin
This is with a VS8 compiled version of ruby.

Given this simple program (foo.rb):
----------->8---------cut--------8<------------
puts "" * 20
p IO.popen('echo HI') {|f| f.readlines}
puts "
" * 20
----------->8---------cut--------8<------------

I get this:
----------->8---------cut--------8<------------
E:\test>bin\ruby.exe foo.rb


The handle is invalid.
[]


E:\test>
----------->8---------cut--------8<------------

Interestingly, if I redirect to a file, it works:
----------->8---------cut--------8<------------
E:\test>bin\ruby.exe foo.rb > q

E:\test>type q


["HI\n"]


E:\test>
----------->8---------cut--------8<------------

I'm not sure what is going on, but I know that the python group had similar problems in python < 2.6.... maybe we can crib their solution?

Ciao!

Python URLs:
http://bytes.com/topic/python/answers/634409-subprocess-handle-invalid-error
http://bugs.python.org/issue1124861 -- The patch is interesting.
=end

Also available in: Atom PDF