aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/ptfork.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-05-28 22:14:55 +0000
committerUlrich Drepper <drepper@redhat.com>2000-05-28 22:14:55 +0000
commitc0f3519d2e841dbaad086091f610cebc8178e7f6 (patch)
tree8ca703fea57ed1eefb8f5f102e2c166f5a1f912d /linuxthreads/ptfork.c
parent2588068bdf891c057443ecfee136fb1bcfc3bf38 (diff)
downloadglibc-c0f3519d2e841dbaad086091f610cebc8178e7f6.tar
glibc-c0f3519d2e841dbaad086091f610cebc8178e7f6.tar.gz
glibc-c0f3519d2e841dbaad086091f610cebc8178e7f6.tar.bz2
glibc-c0f3519d2e841dbaad086091f610cebc8178e7f6.zip
Update.
* posix/Makefile (tests): Add tst-fork.
Diffstat (limited to 'linuxthreads/ptfork.c')
-rw-r--r--linuxthreads/ptfork.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/linuxthreads/ptfork.c b/linuxthreads/ptfork.c
index cb6d46db8c..440d66c4a3 100644
--- a/linuxthreads/ptfork.c
+++ b/linuxthreads/ptfork.c
@@ -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;
}