Re: request for help



Le mar, 21 aoû 2001 12:06:19, Brian Stafford a écrit :
> I remembered the name of the function: its pthread_atfork().
> 
> >From "man pthread_atfork"
> 
>        To  understand  the purpose of pthread_atfork, recall that
>        fork(2)  duplicates  the  whole  memory  space,  including
>        mutexes in their current locking state, but only the call­
>        ing thread: other threads are not  running  in  the  child
>        process. Thus, if a mutex is locked by a thread other than
>        the thread calling fork, that  mutex  will  remain  locked
>        forever in the child process, possibly blocking the execu­
>        tion of the child process. To avoid this, install handlers
>        with  pthread_atfork as follows: the prepare handler locks
>        the global mutexes (in locking order), and the parent  and
>        child  handlers  unlock  them (in reverse order). Alterna­
>        tively, prepare and parent can be set to NULL and child to
>        a  function  that  calls  pthread_mutex_init on the global
>        mutexes.
> 
> Hope this is of use.

This sound really good.
This should fix all pthread issues.

Christophe

-- 
Christophe Barbé
Software Engineer - christophe.barbe@lineo.fr
Lineo France - Lineo High Availability Group
42-46, rue Médéric - 92110 Clichy - France
phone (33).1.41.40.02.12 - fax (33).1.41.40.02.01
http://www.lineo.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]