From: Bertram Scharpf Date: 2009-01-21T20:41:54+09:00 Subject: Re: Threads After Fork Hi, Am Mittwoch, 21. Jan 2009, 04:48:14 +0900 schrieb James Gray: > On Jan 20, 2009, at 1:42 PM, Tim Pease wrote: >> On Jan 20, 2009, at 8:55 AM, James Gray wrote: >> >>> printer = Thread.new do >>> 10.times do >>> sleep 1 >>> puts "Thread running in #{Process.pid}..." >>> end >>> end >>> >>> fork do >>> p [Process.pid, printer.status] >>> printer.join >>> end >>> >>> Are all other threads stopped as part of a process fork? >> >> fork doesn’t copy other threads. > > Man, I swear I've read that documentation 400 times now and just keep > missing that. A soothing fact that even the well-experienced Ruby programmer sometimes detects new aspects. I think the amazing strike is that the variable containing the Thread instance still exists whilst the Thread will surely be dead. Joining a dead thread does just nothing. I reduced it to these two lines: t = Thread.new do sleep 100 end fork do puts t.inspect end Output: # Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de