lib/cobalt: start helper thread with signals blocked
PATCH 1/2 lib/cobalt: start helper thread with signals blocked
Delivery mechanisms like sigwait and signalfd require *all* threads to block the relevant signals.
The cobalt init should not spawn a thread affecting the signal-handling.
Signed-off-by Norbert Lange <[email protected]>
--- lib/cobalt/printf.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/cobalt/printf.c +5 -0
@@ -20,6 +20,7 @@#include <inttypes.h> #include <limits.h> #include <pthread.h> +#include <signal.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h>
@@ -640,9 +641,13 @@ static void *printer_loop(void *arg)static void spawn_printer_thread (void ) {pthread_attr_t thattr; +sigset_t sset, oset;pthread_attr_init (&thattr); +sigfillset (&sset); +pthread_sigmask (SIG_BLOCK , &sset, &oset);pthread_create (&printer_thread, &thattr, printer_loop,NULL ); +sigprocmask (SIG_SETMASK , &oset,NULL ); }void cobalt_print_init_atfork (void )
Signature · 1 line
2.20.1
PATCH 2/2 lib/cobalt: set name for printf thread to help debugging
Signed-off-by Norbert Lange <[email protected]>
--- lib/cobalt/printf.c | 1 + 1 file changed, 1 insertion(+)
lib/cobalt/printf.c +1 -0
@@ -648,6 +648,7 @@ static void spawn_printer_thread(void)pthread_sigmask (SIG_BLOCK , &sset, &oset);pthread_create (&printer_thread, &thattr, printer_loop,NULL );sigprocmask (SIG_SETMASK , &oset,NULL ); +pthread_setname_np (printer_thread,"cobalt_printf" ); }void cobalt_print_init_atfork (void )
Signature · 1 line
2.20.1
Re: [PATCH 2/2] lib/cobalt: set name for printf thread to help debugging
Quoted 11 lines · Norbert Lange via Xenomai
Signed-off-by Norbert Lange <[email protected]>--- lib/cobalt/printf.c | 1 + 1 file changed, 1 insertion(+)lib/cobalt/printf.c +0
-0
lib/cobalt/printf.c static void spawn_printer_thread(void) · line 654
Quoted 7 lines
lib/cobalt/printf.c +1
-0@@ -648,6 +648,7 @@ static void spawn_printer_thread(void)pthread_sigmask (SIG_BLOCK , &sset, &oset);pthread_create (&printer_thread, &thattr, printer_loop,NULL );sigprocmask (SIG_SETMASK , &oset,NULL ); +pthread_setname_np (printer_thread,"cobalt_printf" ); }void cobalt_print_init_atfork (void )
Thanks, both applied.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux