From: Ken Hilton Date: 2004-04-28T04:34:04+09:00 Subject: $stdin, thread blocking and DRb (for lack of a better subject :) Greetings friends in Ruby-land, I've crafted a Ruby application and its giving me a little trouble and I'm hoping someone out there can give me some insight into the problem. The app is composed of 3 threads (other than the primary thread, which waits for the others to finish once its created them): the first thread is bound to a code block which reads email via NET::POP3; the 2nd thread is that of a simple DRb server; and the third thread is bound to a code block that implements a simple command shell which reads lines from $stdin. The application works wonderfully but w/the following problem: threads 1 and 2 block when the command shell thread reads from $stdin. Adjusting thread priorities had no affect on the problem. When the command shell thread is stopped all works as expected (email is read in the background and in parallel w/the DRb server accepting requests from an test harness running as a separate ruby session.) I've checked all the Ruby books and docs I have and can't find an explanation as to why this should be happening. My suspicion is that because $stdin belongs to the ruby application main thread and is being used by the command shell thread, that for some reason the blocking read of $stdin is holding off the other threads. This speculation is supported by the fact that entering a command to the shell allows all 3 threads to run in parallel until the command is completed and the next read of $stdin occurs. Any insight ya'll can lend will be much appreciated. Ken.