Changeset View
Changeset View
Standalone View
Standalone View
lib/libthr/thread/thr_fork.c
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | __thr_fork(void) | ||||
/* | /* | ||||
* All bets are off as to what should happen soon if the parent | * All bets are off as to what should happen soon if the parent | ||||
* process was not so kindly as to set up pthread fork hooks to | * process was not so kindly as to set up pthread fork hooks to | ||||
* relinquish all running threads. | * relinquish all running threads. | ||||
*/ | */ | ||||
if (_thr_isthreaded() != 0) { | if (_thr_isthreaded() != 0) { | ||||
was_threaded = 1; | was_threaded = 1; | ||||
__thr_malloc_prefork(curthread); | |||||
_malloc_prefork(); | _malloc_prefork(); | ||||
__thr_pshared_atfork_pre(); | __thr_pshared_atfork_pre(); | ||||
_rtld_atfork_pre(rtld_locks); | _rtld_atfork_pre(rtld_locks); | ||||
} else { | } else { | ||||
was_threaded = 0; | was_threaded = 0; | ||||
} | } | ||||
/* | /* | ||||
Show All 11 Lines | if (ret == 0) { | ||||
curthread->flags &= ~(THR_FLAGS_NEED_SUSPEND|THR_FLAGS_DETACHED); | curthread->flags &= ~(THR_FLAGS_NEED_SUSPEND|THR_FLAGS_DETACHED); | ||||
/* | /* | ||||
* Thread list will be reinitialized, and later we call | * Thread list will be reinitialized, and later we call | ||||
* _libpthread_init(), it will add us back to list. | * _libpthread_init(), it will add us back to list. | ||||
*/ | */ | ||||
curthread->tlflags &= ~TLFLAGS_IN_TDLIST; | curthread->tlflags &= ~TLFLAGS_IN_TDLIST; | ||||
/* before thr_self() */ | |||||
if (was_threaded) | |||||
__thr_malloc_postfork(curthread); | |||||
/* child is a new kernel thread. */ | /* child is a new kernel thread. */ | ||||
thr_self(&curthread->tid); | thr_self(&curthread->tid); | ||||
/* clear other threads locked us. */ | /* clear other threads locked us. */ | ||||
_thr_umutex_init(&curthread->lock); | _thr_umutex_init(&curthread->lock); | ||||
_mutex_fork(curthread); | _mutex_fork(curthread); | ||||
_thr_signal_postfork_child(); | _thr_signal_postfork_child(); | ||||
Show All 28 Lines | if (ret == 0) { | ||||
curthread->no_cancel = cancelsave; | curthread->no_cancel = cancelsave; | ||||
} else { | } else { | ||||
/* Parent process */ | /* Parent process */ | ||||
errsave = errno; | errsave = errno; | ||||
_thr_signal_postfork(); | _thr_signal_postfork(); | ||||
if (was_threaded) { | if (was_threaded) { | ||||
__thr_malloc_postfork(curthread); | |||||
_rtld_atfork_post(rtld_locks); | _rtld_atfork_post(rtld_locks); | ||||
__thr_pshared_atfork_post(); | __thr_pshared_atfork_post(); | ||||
_malloc_postfork(); | _malloc_postfork(); | ||||
} | } | ||||
/* Ready to continue, unblock signals. */ | /* Ready to continue, unblock signals. */ | ||||
_thr_signal_unblock(curthread); | _thr_signal_unblock(curthread); | ||||
Show All 16 Lines |