From: Francis Cianfrocca Date: 2006-08-27T23:54:46+09:00 Subject: Re: Ruby threads and the system call ------=_Part_21203_15057184.1156690482805 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/27/06, Vincent Fourmond wrote: > > > Hello ! > > I've recently had quite a fair bit of trouble with Ruby threads (on a > Linux box). I wrote three different programs (attached) that write > numbers from within threads: > > * one with a standard puts > * one with a system "echo ..." > * one with a fork do system "echo ..." end Both fork and the system call have the effect of creating a subprocess which then interacts with your main process through open file descriptors and through signals. Both interact badly with threads. I suggest you consider a non-threaded design, fork off your subprocesses, and use waitpid2 to distinguish the various returns. If you need to capture data generated by print statements in the subprocesses, then you can play painful games like redirecting the standard file descriptors to other file numbers, or you can simply make sure you only have one subprocess in flight at a time. ------=_Part_21203_15057184.1156690482805--