[Win32utils-devel] Fwd: Is select() untrustworthy on Windows when used with handles from popen3?

Daniel Berger djberg96 at gmail.com
Fri Mar 21 13:30:13 EDT 2008


Any ideas?

Dan


---------- Forwarded message ----------
From: Steve Shreeve <steve.shreeve at gmail.com>
Date: Thu, Mar 13, 2008 at 10:51 AM
Subject: Is select() untrustworthy on Windows when used with handles
from popen3?
To: djberg96 at gmail.com




Dan,

Thanks for your work on the win32util modules.

I've created an expect-like library that allows one to easily script
interactions with non-GUI applications. Everything works great when
connecting to the target system using a socket, or using PTY.spawn on
Linux. On Windows, I get quite a bit of grief. Here's an example that
has me confused:

d:\>irb
irb(main):001:0> require 'win32/open3'
=> true
irb(main):002:0> i,o,e = Open3.popen3('date')
=> [#<IO:0x2b42a4c>, #<IO:0x2b42a24>, #<IO:0x2b42a10>, 3164]
irb(main):003:0> o.sysread(70)
=> "The current date is: Thu 03/13/2008 \nEnter the new date: (mm-dd-yy) "
irb(main):004:0> select([o],nil,nil,1)
=> [[#<IO:0x2b42a24>], [], []]
irb(main):005:0> o.sysread(1)
# => here, it hangs... even though it *says* there's input to read ]==

Since we hang at this spot, I'm sorta hosed... how can I trust select()?

Steve

==

ps - I'd be happy to pay for your time to assist with this.


More information about the win32utils-devel mailing list