On Tue, Jan 29, 2008 at 10:22:16PM +0200, Paul Sheer wrote:
> >
> >
> > I find it hard to believe that there exists a platform where:
> >
> 
> On FreeBSD/OpenBSD my program outright core dumped and I could not
> figure out why for days and days. Now I have two separate builds - one built
> with "-D_REENTRANT -DTHREADS ... -lpthread" and one without.
> Only with Linux do you have the freedom of which you speak.
> 
> Well lets ask this question: "does fork() replicate all Thread Local Storage
> data or not?"  It certainly replicates the heap. It replicates all static
> data. It
> replicates all global data. But TLS? What does POSIX say about that?

     * A process shall be created with a single thread. If a
       multi-threaded process calls fork(), the new process shall contain
       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. ^[THR] [Option Start]  Fork handlers may be
       established by means of the pthread_atfork() function in order to
       maintain application invariants across fork() calls. [Option End]
       When the application calls fork() from a signal handler and any of
       the fork handlers registered by pthread_atfork() calls a function
       that is not asynch-signal-safe, the behavior is undefined.

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


Kurt

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to