Subject: Re: fork(2) vs. pthread_create() (fwd)
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Giles Lean <giles@nemeton.com.au>
List: tech-userlevel
Date: 06/09/2004 18:25:51
Emmanuel Dreyfus <manu@netbsd.org> wrote:

> 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.

Welcome to the not-so-wonderful world of threads programming.  I'm only
surprised that this appears to work on other platforms, and like Nathan
I wonder if it really works or if it just happens not to fall over?

Taking almost every lock known to libc before calling fork() might let
this work ... at a cost of making a call to fork() from a threaded
program that only wants to immediately call exec more expensive than it
needs to be, and opening new opportunities for deadlocks.  Hmm.

Perhaps someone more curious than I am can look at the Linux and/or
FreeBSD implementations, and see what they actually do?

Giles