pthreads

Robert Collins robert.collins@itdomain.com.au
Mon Mar 19 03:09:00 GMT 2001


----- Original Message -----
From: "Robert Collins" <robert.collins@itdomain.com.au>
To: <cygwin-developers@cygwin.com>
Sent: Monday, March 19, 2001 8:22 AM
Subject: Re: pthreads


> ----- Original Message -----
> From: "Chris Faylor" <cgf@redhat.com>
> To: "Robert Collins" <robert.collins@itdomain.com.au>
> Cc: <cygwin-developers@cygwin.com>
> Sent: Monday, March 19, 2001 4:06 AM
> Subject: Re: pthreads
>
>
>Thread state should not be copied since fork does not duplicate
threads.

I've gone and done my homework :]

http://www.opengroup.org/onlinepubs/007908799/xsh/fork.html
"A process is created with a single thread. If a multi-threaded process
calls fork(), the new process contains 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. Fork handlers may be established by means
of the pthread_atfork() function in order to maintain application
invariants across fork() calls. "
So the current behaviour _is correct_. I'm not 100% sure we follow the
calling thread's state rather than the mainthreads state, but I'll look
into that. I'll look into an implementation of the pthread_atfork stuff
next weekend I think (hey may as well get on a roll with this stuff).


> Thanks, the opengroup specs don'y mention fork/thread interaction in
the
> thread call documentation - which is why I asked.

(but I found that they do under fork(). :])

> Does
> > linux duplicate every thread in a forked child?
>
> I'll go read.

No. See above.

Rob





More information about the Cygwin-developers mailing list