Bug #3215
closedWindows: IO.popen returns "handle is invalid"
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
Updated by rogerdpack (Roger Pack) over 14 years ago
=begin
seems to work ok with mingw, if that's any help (which it's not, but still a clue).
=end
Updated by jonforums (Jon Forums) over 14 years ago
=begin
When using the mingw v3.4.5 built 1.9.1p378 from http://rubyinstaller.org/ the example snippet also works for me (Win7 Ultimate 32-bit) as well as the IO.popen code from the following patch I use with Jekyll
http://github.com/jonforums/jekyll/commit/237b8ebe1defdee92afc5dc146a4d89058a16c37
=end
Updated by usa (Usaku NAKAMURA) over 14 years ago
- Status changed from Open to Feedback
- Priority changed from Normal to 3
=begin
on XP x64, with both of 1.9.1p376 and trunk, I couldn't reproduce it.
Christian, what is your OS?
=end
Updated by docwhat (Christian Höltje) over 14 years ago
=begin
It is Windows 2003 Server. I connect via rdesktop. I'm using Visual Studio 8 (aka 2005) to compile ruby. I don't know if it happens with mingw, etc.
If you are able to compile ruby 1.9.1-p376 using VS8, I'd love to swap patches and work-arounds for problems. I've filed bugs for all the obvious ones.
=end
Updated by docwhat (Christian Höltje) over 14 years ago
=begin
Hmm....it looks like I can't reliably recreate this. I'm not sure why it works sometimes and not others.
=end
Updated by jeremyevans0 (Jeremy Evans) about 5 years ago
- Description updated (diff)
- Status changed from Feedback to Closed