tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/42772 -- pthread issue with fork()



On 3/23/10 7:08 PM, Joerg Sonnenberger wrote:
> On Tue, Mar 23, 2010 at 07:03:11PM -0700, Michael Graff wrote:
>> I'd like to commit it (and request a pull-up to netbsd-5).  Any reason I
>> shouldn't?
> 
> What is the real problem here? fork(2) of a multithreaded program is
> essentially "Here be dragon's" terrain. So I don't think why it matters
> at all given the pthread functions are generally not async-safe.

I believe the belief (either mistakenly by Ruby, which works on other
OS's pthreads just fine...) is that the fork()ed process can use pthread
calls just fine.  It might get its own environment (that is, it is as if
it were the main thread and pthread_init() had been called to set things
up.)

This patch seems to make this work as expected, by setting the current
thread in the child to thread id 1, rather than leaving it unset.
pthread_create() creates id 2 within the child as well.

--Michael


Home | Main Index | Thread Index | Old Index