Changeset View
Changeset View
Standalone View
Standalone View
lib/libthr/thread/thr_fork.c
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
#include "libc_private.h" | #include "libc_private.h" | ||||
#include "rtld_lock.h" | #include "rtld_lock.h" | ||||
#include "thr_private.h" | #include "thr_private.h" | ||||
__weak_reference(_thr_atfork, _pthread_atfork); | __weak_reference(_thr_atfork, _pthread_atfork); | ||||
__weak_reference(_thr_atfork, pthread_atfork); | __weak_reference(_thr_atfork, pthread_atfork); | ||||
bool _thr_after_fork = false; | |||||
int | int | ||||
_thr_atfork(void (*prepare)(void), void (*parent)(void), | _thr_atfork(void (*prepare)(void), void (*parent)(void), | ||||
void (*child)(void)) | void (*child)(void)) | ||||
{ | { | ||||
struct pthread *curthread; | struct pthread *curthread; | ||||
struct pthread_atfork *af; | struct pthread_atfork *af; | ||||
_thr_check_init(); | _thr_check_init(); | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | if (ret == 0) { | ||||
/* 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(); | ||||
if (was_threaded) { | if (was_threaded) { | ||||
_thr_after_fork = true; | |||||
_rtld_atfork_post(rtld_locks); | _rtld_atfork_post(rtld_locks); | ||||
_thr_after_fork = false; | |||||
__thr_pshared_atfork_post(); | __thr_pshared_atfork_post(); | ||||
} | } | ||||
_thr_setthreaded(0); | _thr_setthreaded(0); | ||||
/* reinitalize library. */ | /* reinitalize library. */ | ||||
_libpthread_init(curthread); | _libpthread_init(curthread); | ||||
/* atfork is reinitialized by _libpthread_init()! */ | /* atfork is reinitialized by _libpthread_init()! */ | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |