diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-08-28 22:08:39 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-08-28 22:09:29 +0200 |
commit | 17a62de1ff4c7548748a8d264382131f523f071a (patch) | |
tree | 8751a44b0738acbc264930a4e0d2a11c0bf499de /sysdeps/mach | |
parent | 9570bc53fcc11d3cfe028989e611266e8d55bd09 (diff) | |
download | glibc-17a62de1ff4c7548748a8d264382131f523f071a.tar glibc-17a62de1ff4c7548748a8d264382131f523f071a.tar.gz glibc-17a62de1ff4c7548748a8d264382131f523f071a.tar.bz2 glibc-17a62de1ff4c7548748a8d264382131f523f071a.zip |
Fix hang on fork
If e.g. a signal is being received while we are running fork(), the signal
thread may be having our SS lock when we make the space copy, and thus in the
child we can not take the SS lock any more.
* sysdeps/mach/hurd/fork.c (__fork): Lock SS->lock around __proc_dostop call.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'sysdeps/mach')
-rw-r--r-- | sysdeps/mach/hurd/fork.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c index 60c34c7620..51bc2c0753 100644 --- a/sysdeps/mach/hurd/fork.c +++ b/sysdeps/mach/hurd/fork.c @@ -129,9 +129,13 @@ __fork (void) ports_locked = 1; + /* Keep our SS locked while stopping other threads, so they don't get a + chance to have it locked in the copied space. */ + __spin_lock (&ss->lock); /* Stop all other threads while copying the address space, so nothing changes. */ err = __proc_dostop (_hurd_ports[INIT_PORT_PROC].port, ss->thread); + __spin_unlock (&ss->lock); if (!err) { stopped = 1; |