mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
lib: block signals in child pthreads
Block signals in child/additional pthreads; frr daemons generally expect that only the main thread will handle signals. Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
parent
1cbb3675f2
commit
f4635e33a6
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue