Subject: Re: fork(2) vs. pthread_create() (fwd)
To: Jason Thorpe <firstname.lastname@example.org>
From: Nathan J. Williams <email@example.com>
Date: 06/09/2004 19:18:25
Jason Thorpe <firstname.lastname@example.org> writes:
> On Jun 9, 2004, at 1:43 AM, 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.
> Of course it is still threaded... you simply only have one (the main)
> thread at the time.
That explanation would imply that the async-signal-safe restriction on
child-called functions is always true, even when a program that makes
no pthread_create() calls forks. That's not correct.
I think the intent of the standard is that successfully calling
pthread_create() irrevocably changes the state of a process into
"multi-threaded mode", regardless of the number of threads in
existence at a given moment. I am not, however, certain that this
intent was formalized properly.