pid_t __fork(void) { pid_t pid; struct handler_list * prepare, * child, * parent; pthread_mutex_lock(&pthread_atfork_lock); prepare = pthread_atfork_prepare; child = pthread_atfork_child; parent = pthread_atfork_parent; pthread_mutex_unlock(&pthread_atfork_lock); pthread_call_handlers(prepare); #warning hack alert __MALLOC_LOCK; pid = __libc_fork(); #warning hack alert __MALLOC_UNLOCK; if (pid == 0) { __pthread_reset_main_thread(); #warning need to reconsider __fresetlockfiles! __fresetlockfiles(); pthread_call_handlers(child); } else { pthread_call_handlers(parent); } return pid; }
static pid_t __fork(void) { pid_t pid; struct handler_list * prepare, * child, * parent; __pthread_mutex_lock(&pthread_atfork_lock); prepare = pthread_atfork_prepare; child = pthread_atfork_child; parent = pthread_atfork_parent; pthread_call_handlers(prepare); __pthread_once_fork_prepare(); #ifdef __MALLOC__ __pthread_mutex_lock(&__malloc_sbrk_lock); __pthread_mutex_lock(&__malloc_heap_lock); #ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__ __pthread_mutex_lock(&__malloc_mmb_heap_lock); #endif #elif defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__) __pthread_mutex_lock(&__malloc_lock); #endif pid = __libc_fork(); if (pid == 0) { #if defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__) __libc_lock_init_recursive(__malloc_lock); #elif defined(__MALLOC__) #ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__ __libc_lock_init_adaptive(__malloc_mmb_heap_lock); #endif __libc_lock_init_adaptive(__malloc_heap_lock); __libc_lock_init(__malloc_sbrk_lock); #endif __libc_lock_init_adaptive(pthread_atfork_lock); __pthread_reset_main_thread(); __fresetlockfiles(); __pthread_once_fork_child(); pthread_call_handlers(child); } else { #if defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__) __pthread_mutex_unlock(&__malloc_lock); #elif defined(__MALLOC__) #ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__ __pthread_mutex_unlock(&__malloc_mmb_heap_lock); #endif __pthread_mutex_unlock(&__malloc_heap_lock); __pthread_mutex_unlock(&__malloc_sbrk_lock); #endif __pthread_mutex_unlock(&pthread_atfork_lock); __pthread_once_fork_parent(); pthread_call_handlers(parent); } return pid; }
pid_t __fork (void) { return __libc_fork (); }
pid_t fork() { return __libc_fork(); }