On Mon, Dec 18, 2006 at 08:55:10AM +0900, Michael W. Ryder wrote: > I am a veteran programmer but still am trying to learn Ruby. In the > language I have been using for over 25 years input has an option to > terminate after x number of seconds, something that seems to be missing > in Ruby. I use this ability to log off sessions when the user leaves > the computer for a time along with other purposes. > Is it possible in Ruby to use two threads for input, one for reading > from the selected source and the second that would terminate the first > thread if it hadn't completed in the specified amount of time? The main > program would start the first thread and feed the PID to the second > thread along with the number of seconds, or milliseconds, to sleep. The > second thread would then see if the first thread is still alive when it > wakes up and if so terminate it. Either way the second thread would > exit after the number of seconds given. Check out Timeout in the standard lib. http://www.ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html