diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-09-24 23:08:15 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-10-04 22:29:51 +0200 |
commit | 7b7bab1391a3b16fff7e325e2c8a36b68eacba90 (patch) | |
tree | 848fcc756eec599c6b5b9137207a5c8c634d7d64 /sysdeps/mach/hurd | |
parent | d39baad11e5092b56621902f8406c64c092a90dc (diff) | |
download | glibc-7b7bab1391a3b16fff7e325e2c8a36b68eacba90.tar glibc-7b7bab1391a3b16fff7e325e2c8a36b68eacba90.tar.gz glibc-7b7bab1391a3b16fff7e325e2c8a36b68eacba90.tar.bz2 glibc-7b7bab1391a3b16fff7e325e2c8a36b68eacba90.zip |
Add fork hooks for pthread_atfork
pthread_atfork needs application callbacks to be called outside any locking.
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r-- | sysdeps/mach/hurd/fork.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c index ab11babffe..321421fbbc 100644 --- a/sysdeps/mach/hurd/fork.c +++ b/sysdeps/mach/hurd/fork.c @@ -34,6 +34,11 @@ symbol_set_declare (_hurd_fork_locks) +/* Application callbacks registered through pthread_atfork. */ +DEFINE_HOOK (_hurd_atfork_prepare_hook, (void)); +DEFINE_HOOK (_hurd_atfork_child_hook, (void)); +DEFINE_HOOK (_hurd_atfork_parent_hook, (void)); + /* Things that want to be called before we fork, to prepare the parent for task_create, when the new child task will inherit our address space. */ DEFINE_HOOK (_hurd_fork_prepare_hook, (void)); @@ -62,6 +67,8 @@ __fork (void) error_t err; struct hurd_sigstate *volatile ss; + RUN_HOOK (_hurd_atfork_prepare_hook, ()); + ss = _hurd_self_sigstate (); __spin_lock (&ss->critical_section_lock); @@ -695,6 +702,14 @@ __fork (void) _hurd_critical_section_unlock (ss); + if (!err) + { + if (pid != 0) + RUN_HOOK (_hurd_atfork_parent_hook, ()); + else + RUN_HOOK (_hurd_atfork_child_hook, ()); + } + return err ? __hurd_fail (err) : pid; } libc_hidden_def (__fork) |