From: James Gray Date: 2009-01-21T04:48:14+09:00 Subject: Re: Threads After Fork On Jan 20, 2009, at 1:42 PM, Tim Pease wrote: > On Jan 20, 2009, at 8:55 AM, James Gray wrote: > >> Am I understanding this example right: >> >> #!/usr/bin/env ruby -wKU >> >> 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 >> >> p [Process.pid, printer.status] >> printer.join >> # >> [457, "sleep"] >> # >> [458, false] >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> # >> Thread running in 457... >> >> __END__ >> >> Are all other threads stopped as part of a process fork? >> > > From the fork documentation .... > > "The thread calling fork is the only thread in the created child > process. fork doesn’t copy other threads." Man, I swear I've read that documentation 400 times now and just keep missing that. Thanks for the reading lesson Tim! James Edward Gray II