summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2020-07-13 11:09:46 -0400
committerGitHub <noreply@github.com>2020-07-13 11:09:46 -0400
commit80fa508153015f488310d07f79d6e38ce1e7cfb6 (patch)
treecbebc661a4a135aa24a554b8784064f144e457d1
parentab05b7f6bd17e53fe4572c9ca65e94e2ff4f92ed (diff)
parentf4635e33a62d6f30339a5d0cfdbfaa90fba1f8df (diff)
Merge pull request #6704 from mjstapp/pthread_block_signals
lib: block signals in child pthreads
-rw-r--r--lib/frr_pthread.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c
index e237934f81..da9594ed80 100644
--- a/lib/frr_pthread.c
+++ b/lib/frr_pthread.c
@@ -159,10 +159,20 @@ static void *frr_pthread_inner(void *arg)
int frr_pthread_run(struct frr_pthread *fpt, const pthread_attr_t *attr)
{
int ret;
+ sigset_t oldsigs, blocksigs;
+
+ /* Ensure we never handle signals on a background thread by blocking
+ * everything here (new thread inherits signal mask)
+ */
+ sigfillset(&blocksigs);
+ pthread_sigmask(SIG_BLOCK, &blocksigs, &oldsigs);
fpt->rcu_thread = rcu_thread_prepare();
ret = pthread_create(&fpt->thread, attr, frr_pthread_inner, fpt);
+ /* Restore caller's signals */
+ pthread_sigmask(SIG_SETMASK, &oldsigs, NULL);
+
/*
* Per pthread_create(3), the contents of fpt->thread are undefined if
* pthread_create() did not succeed. Reset this value to zero.