1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00
* posix/Makefile (tests): Add tst-fork.
This commit is contained in:
Ulrich Drepper
2000-05-28 22:14:55 +00:00
parent 2588068bdf
commit c0f3519d2e
8 changed files with 288 additions and 10 deletions

View File

@@ -78,25 +78,29 @@ extern int __libc_fork(void);
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);
pthread_call_handlers(pthread_atfork_prepare);
__pthread_once_fork_prepare();
pid = __libc_fork();
if (pid == 0) {
__pthread_reset_main_thread();
__fresetlockfiles();
pthread_call_handlers(child);
__pthread_once_fork_child();
pthread_call_handlers(pthread_atfork_child);
pthread_mutex_init(&pthread_atfork_lock, NULL);
} else {
pthread_call_handlers(parent);
__pthread_once_fork_parent();
pthread_call_handlers(pthread_atfork_parent);
pthread_mutex_unlock(&pthread_atfork_lock);
}
return pid;
}