mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-13 00:30:07 +00:00
Add fork hooks for pthread_atfork
pthread_atfork needs application callbacks to be called outside any locking.
This commit is contained in:
parent
d39baad11e
commit
7b7bab1391
@ -1,3 +1,10 @@
|
|||||||
|
2013-10-04 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||||
|
|
||||||
|
* sysdeps/mach/hurd/fork.c (_hurd_atfork_prepare_hook,
|
||||||
|
_hurd_atfork_child_hook, _hurd_atfork_parent_hook): New hooks.
|
||||||
|
(__fork): Call _hurd_atfork_prepare_hook hooks before all locking, call
|
||||||
|
_hurd_atfork_parent_hook or _hurd_atfork_child_hook after all unlocking.
|
||||||
|
|
||||||
2013-10-04 Ryan S. Arnold <ryan.arnold@linaro.org>
|
2013-10-04 Ryan S. Arnold <ryan.arnold@linaro.org>
|
||||||
|
|
||||||
* misc/swapon.c (swapon): Update definition, adding FLAGS parameter to
|
* misc/swapon.c (swapon): Update definition, adding FLAGS parameter to
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
symbol_set_declare (_hurd_fork_locks)
|
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
|
/* 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. */
|
task_create, when the new child task will inherit our address space. */
|
||||||
DEFINE_HOOK (_hurd_fork_prepare_hook, (void));
|
DEFINE_HOOK (_hurd_fork_prepare_hook, (void));
|
||||||
@ -62,6 +67,8 @@ __fork (void)
|
|||||||
error_t err;
|
error_t err;
|
||||||
struct hurd_sigstate *volatile ss;
|
struct hurd_sigstate *volatile ss;
|
||||||
|
|
||||||
|
RUN_HOOK (_hurd_atfork_prepare_hook, ());
|
||||||
|
|
||||||
ss = _hurd_self_sigstate ();
|
ss = _hurd_self_sigstate ();
|
||||||
__spin_lock (&ss->critical_section_lock);
|
__spin_lock (&ss->critical_section_lock);
|
||||||
|
|
||||||
@ -695,6 +702,14 @@ __fork (void)
|
|||||||
|
|
||||||
_hurd_critical_section_unlock (ss);
|
_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;
|
return err ? __hurd_fail (err) : pid;
|
||||||
}
|
}
|
||||||
libc_hidden_def (__fork)
|
libc_hidden_def (__fork)
|
||||||
|
Loading…
Reference in New Issue
Block a user