From: Joel VanderWerf Date: 2006-11-11T06:45:37+09:00 Subject: Re: thread death callback to be called after fork ara.t.howard@noaa.gov wrote: ... > now, say you need to know when a thread has been killed due to forking, it > appears there is no message sent to the thread: Notification would also be useful in case the thread is holding some resource, such as a mutex, when it is killed in the child (as in [1]). Finalizers don't seem right--you have to manage them separately from the normal code to close resources, which is typically in ensure clauses. Maybe fork should, in the child process, keep the other threads alive long enough to raise an exception in them, so that ensure clauses are executed? This would handle all kinds of resources, not just sockets and mutexes. An ensure clause could also keep the thread alive. I'm not sure if this is a bug or a feature, but it sounds right. You might want some of the threads to survive into the fork. There probably isn't a pure ruby way to hack this in, because the threads (other than the running thread) are already dead in the fork as soon as the fork starts executing ruby code. [1] http://wiki.rubygarden.org/Ruby/page/show/ForkableMutex -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407