Joel VanderWerf wrote: > Michael W. Ryder wrote: >> Maybe I am missing something here but it doesn't seem to work for me. >> I have the following simple program: >> >> require 'timeout' >> foo = nil >> status = Timeout::timeout(5) { >> foo = gets() >> } >> puts (foo) >> >> If I enter something, say 123, then the program displays the 123 as >> expected. If I just wait it sits there until I enter something which >> is not what I want. I want the input to terminate and display that >> foo is 'nil'. For some reason testing the value of status shows that >> it is the same as the input, but this may not be relevant to the problem. > > That's a problem with the combination of the msvc-based ruby on windows > and gets and threads (Timeout uses a thread). There was a discussion in > the ruby-talk list with subject "Thread and sleep" a few days ago. > I read that thread which was why I was wondering if one could use two threads, one for the gets, and one to terminate that thread after a period of time if the first thread hadn't already gotten input and terminated. I know that most non-Microsoft based Operating Systems don't have this problem but as Microsoft has the majority of the market programs have to be able to work on their OS. The language I have been using for over 25 years works identically on a very large number of platforms from PCs to mainframes so I would think Ruby would be able to do the same, if not today then in the near future.