[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/42772 -- pthread issue with fork()
On Wed, Mar 24, 2010 at 03:09:19PM -0700, Michael Graff 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.
To quote the SUSv3:
A process shall be created with a single thread. If a multi-threaded
process calls fork(), the new process shall contain a replica of the
calling thread and its entire address space, possibly including the
states of mutexes and other resources. Consequently, to avoid errors,
the child process may only execute async-signal-safe operations until
such time as one of the exec functions is called.
The RATIONALE has a list of many of the issues here.
> 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...
You are confusing something here. The constraints apply to
multi-threaded programs. Most daemons do the double-fork dance early and
start threads afterwards.
Main Index |
Thread Index |