From: "Ara.T.Howard" Date: 2004-02-26T13:44:51+09:00 Subject: Re: thread gurus please help... On Thu, 26 Feb 2004, Joel VanderWerf wrote: > Ara.T.Howard wrote: > > On Wed, 25 Feb 2004, Ara.T.Howard wrote: > > > > forgot to mention that i have $VERBOSE=nil so i don't see the > > > > "...fork terminates thread..." > > > > err msg. i assume that, in this case (forking done in open3) it is OK if that > > thread is terminated in the child - it obviously seem to continue running in > > the parent... > > I've never seen forking have an adverse effect on threads in the parent. > But there is a case where terminating all but one thread, which is what > happens in the child, has an adverse effect. > > require 'thread' > > m = Mutex.new > > Thread.new { m.synchronize { sleep 1 } } > > fork do > m.synchronize { puts "Didn't get here." } > end > > m.synchronize { puts "Got here." } > > Process.wait > > This outputs the warning you saw and "Got here.". wow. that is really bizarre. if i understand correctly all but the 'main' thread is killed so the thread that is sleeping with the lock sort vaporizes and leaves the mutex in an inconsistent (or locked at least) state? > I've gotten around this by explicitly removing the dead threads that hold a > mutex or are waiting for it. (Code available, if anyone's interested.) you are braver than i ;-) > But that doesn't look like your problem, since the child is firing up a > whole new ruby. sort of, the actual fork in my code are many satelite image processing steps and it is done from within popen3 prior to an exec so i should be _ok_. thanks for the reply - i'm feeling alot more confident now. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================