From: Rich Felker Date: Mon, 2 Sep 2013 19:16:36 +0000 (-0400) Subject: in synccall, ignore the signal before any threads' signal handlers return X-Git-Tag: v0.9.14~47 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3c0501d28c1491ce9a4f675e9e223a8dfd9e134c;p=oweals%2Fmusl.git in synccall, ignore the signal before any threads' signal handlers return this protects against deadlock from spurious signals (e.g. sent by another process) arriving after the controlling thread releases the other threads from the sync operation. --- diff --git a/src/thread/synccall.c b/src/thread/synccall.c index c54570be..90ad1e25 100644 --- a/src/thread/synccall.c +++ b/src/thread/synccall.c @@ -71,6 +71,10 @@ void __synccall(void (*func)(void *), void *ctx) sigqueue(self->pid, SIGSYNCCALL, (union sigval){0}); while (sem_wait(&chaindone)); + sa.sa_flags = 0; + sa.sa_handler = SIG_IGN; + __libc_sigaction(SIGSYNCCALL, &sa, 0); + for (cur=head; cur; cur=cur->next) { sem_post(&cur->sem); while (sem_wait(&cur->sem2)); @@ -82,10 +86,6 @@ void __synccall(void (*func)(void *), void *ctx) sem_post(&cur->sem); } - sa.sa_flags = 0; - sa.sa_handler = SIG_IGN; - __libc_sigaction(SIGSYNCCALL, &sa, 0); - __syscall(SYS_rt_sigprocmask, SIG_SETMASK, &oldmask, 0, _NSIG/8);