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/24/10 3:09 AM, Andrew Doran wrote:

The comment that pthread_* functions cannot safely be used in the forked
child is not QUITE what I understand to be what POSIX has in mind.  They
say only one thread is running (that is, the child's MAIN thread).
Creating another thread afterwards should be something that is both
expected and indeed may in fact be typical.

Consider the method to become a daemon, you fork() then let the child
continue.  Surely we're not saying you cannot use pthread_create() there...

> - I think this should be in pthread__fork_callback().

This fixes things for the first fork() but I'm not certain
pthread__init() is actually called for the child to set up correctly for
the next fork().

> - pthread__start() and all related stuff like use of pthead_started seem
>   to be leftovers from SA that we no longer need.

I don't think I can be the one doing that cleanup. :)

> - pthread_self() call should be pthread__self() (libpthread internal).
> - please put "pthread_t self;" at top of function.

Done.



Home | Main Index | Thread Index | Old Index