Project

General

Profile

Bug #3215

Windows: IO.popen returns "handle is invalid"

Added by docwhat (Christian Höltje) over 9 years ago. Updated 20 days 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

History

#1

Updated by rogerdpack (Roger Pack) over 9 years ago

=begin
seems to work ok with mingw, if that's any help (which it's not, but still a clue).
=end

#2

Updated by jonforums (Jon Forums) over 9 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

#3

Updated by usa (Usaku NAKAMURA) over 9 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

#4

Updated by docwhat (Christian Höltje) over 9 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

#5

Updated by docwhat (Christian Höltje) over 9 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

#6

Updated by jeremyevans0 (Jeremy Evans) 20 days ago

  • Status changed from Feedback to Closed
  • Description updated (diff)

Also available in: Atom PDF