Subject: Re: fork(2) vs. pthread_create() (fwd)
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Martin Husemann <martin@duskware.de>
List: tech-userlevel
Date: 06/09/2004 11:03:53
On Wed, Jun 09, 2004 at 08:43:40AM +0000, Emmanuel Dreyfus wrote:
> Before forking, I joined the exisiting thread, thus reverting to a single
> threaded process. The problem is that the process remebers it has been 
> threaded when I hit the fork, whereas it is not threaded anymore.

I don't think that your program ever can become non multi-threaded
again after having called pthread_create().

Posix says:

 When a programmer is writing a multi-threaded program, the first described
 use of fork(), creating new threads in the same program, is provided by the
 pthread_create() function. The fork() function is thus used only to run new
 programs, and the effects of calling functions that require certain resources
 between the call to fork() and the call to an exec function are undefined.

Martin