Subject: Re: fork(2) vs. pthread_create() (fwd)
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: tech-userlevel
Date: 06/08/2004 22:42:53
manu@netbsd.org (Emmanuel Dreyfus) writes:

> > Notably, none of the pthread_* functions are async-signal-safe.
> > 
> > In order for this to work, there would have to be a fork handler that
> > reset all of libpthread's state to initialization values, and the
> > child program would still suffer severe constraints on what program
> > mutexes or variables it could use (consider, for example, the state of
> > stdio mutexes at the moment of fork()).
> 
> I don't find this very satisfaying. Forking from a program that executed
> threads works on Linux and FreeBSD. It's not an extraordinary scenario.

It works in the intended and common case, where you fork() in order to
exec() something. I am also skeptical that it truly works on Linux and
FreeBSD; I suspect some fun with flockfile(stdout) could demonstrate
that.

        - Nathan