On Fri, 23 Jun 2006, Han Holl wrote: > Hello, > > If I fork a (Linux) process with a DRb client, both parent and child will > communicate with the DRb server using the same Unix Domain sockets. With > predictable, nasty results. > > Is there a way for the child to somhow destroy its DRb::DRbObject and create > a new ? > > I've scanned the source, but found nothing useful. > > Any suggestions ? > > Cheers, > > Han Holl this seems ok: harp:~ > cat a.rb require 'drb' require 'tmpdir' require 'yaml' STDOUT.sync = STDERR.sync = true # # setup unix domain drb server in another process # r, w = IO.pipe uri = nil cid = fork unless cid r.close sok = File.join Dir.tmpdir, Process.pid.to_s at_exit{ File.unlink sok } uri = "drbunix://#{ sok }" (list = []).extend DRbUndumped DRb.start_service uri, 'children' => list, 'parent' => nil w.puts uri Thread.new(Thread.current) do |cur| begin w.puts "no zombies" rescue Exception cur.exit end end DRb.thread.join else w.close uri = r.gets.strip end # # attach a client to it # DRb.start_service dhash = DRbObject.new nil, uri dhash['parent'] = Process.pid # # dump info # y 'uri' => uri y 'parent' => dhash['parent'] y 'children' => dhash['children'].map # # fork a few children - each one tears down and sets up client again # 3.times do cid = fork unless cid DRb.stop_service DRb.start_service dhash = DRbObject.new nil, uri dhash['children'] << Process.pid exit else Process.wait end end # # dump info # y 'uri' => uri y 'parent' => dhash['parent'] y 'children' => dhash['children'].map harp:~ > ruby a.rb uri: drbunix:///tmp/15163 parent: 15162 children: [] uri: drbunix:///tmp/15163 parent: 15162 children: - 15165 - 15167 - 15169 regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama