From: Bill Atkins Date: 2005-08-11T23:37:05+09:00 Subject: Re: Threading on Win32 - at an impasse Sure. This solution might not work for everyone, because fortunately I don't really have to do much interprocess communication aside from being able to start and stop children at will. So I have a simulation class: require 'win32/process' class Simulation .... blah blah blah def start @pid = Process.run "ruby bin/run_device.rb #@dev_name #@name" end def kill Process.kill 9, @pid if @pid @pid = nil end .......blah blah blah end And the bin/run_device.rb file loads up the appropriate simulation and does its thing in the background. run_device.rb is the important part - it is more or less my answer to Win32's lack of fork; it loads the library files it needs and then starts up the simulator, so it's as if I've forked the process, but not really. :) run_device.rb's code is long and not too interesting (and application-dependent in any case), so I won't post it here. Process.run is a custom function that Does The Right Thing based on what OS the program is running on: module Process def self.run app if RUBY_PLATFORM =~ /win32/ puts "calling create" Process.create :app_name => app else puts "calling fork" fork do exec app end end end end If only Microsoft would implement fork/exec........ Sigh. Hope that helps, Bill On 8/11/05, Ara.T.Howard wrote: > On Thu, 11 Aug 2005, Bill Atkins wrote: > > > All right, just in case anyone googles this later on, I was able to > > get my application working with the help of win32-process. I used > > separate processes instead of threads, because calling gets on stdin > > seems to block all threads no matter what. > > > > So it seems like separate processes are the way to go, at least until > > Ruby 2.0 (or whenever it gets native threads). > > can you post a baby example? > > cheers. > > -a > -- > =============================================================================== > | email :: ara [dot] t [dot] howard [at] noaa [dot] gov > | phone :: 303.497.6469 > | Your life dwells amoung the causes of death > | Like a lamp standing in a strong breeze. --Nagarjuna > =============================================================================== > > > -- Bill Atkins