From: "Christian Höltje" Date: 2010-04-28T22:47:38+09:00 Subject: [ruby-core:29845] [Bug #3215] Windows: IO.popen returns "handle is invalid" Bug #3215: Windows: IO.popen returns "handle is invalid" http://redmine.ruby-lang.org/issues/show/3215 Author: Christian H��ltje Status: Open, Priority: Normal ruby -v: ruby 1.9.1p376 (2009-12-07) [x64-mswin64_80] 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. ---------------------------------------- http://redmine.ruby-lang.org