On 1/4/10, Caleb Clausen <vikkous / gmail.com> wrote:
> On 1/4/10, Shay Hawkins <gohegdeh / comcast.net> wrote:
>> It creates the thread properly, but when the sleep expires and it is
>> ready to call stdin.puts(), it cannot do anything, because the loop
>> continued around and it is reading from stderr. However, when it
>> receives a new set of input from stderr, since the stream is momentarily
>> being unused, it can then grab the stdin stream and properly input the
>> old line.
>
> Ah, that's right. On windows, there's a special method you have to use
> instead of select to check if input is available on a pipe. Let's see
> ..... I believe the method you're looking for is kbhit (or _kbhit
> maybe? ms likes their underscores...) Check this page on MSDN:
>   http://msdn.microsoft.com/en-us/library/58w7c94c(VS.80).aspx
>
> There should be some library somewhere that makes this available to
> you in rubyland.... Unfortunately, it does mean you have to poll the
> pipe for available input instead of letting it notify you.

Except when I actually read the msdn link above, I see it only works
with stdin... that may not help you. I think there might be some other
windows-specific call you can make that checks any fd for input
availability... you might have to hunt around to find it, or ask on a
windows programming list.