@@ -45,6 +45,33 @@ bool frr_sigevent_check(sigset_t *setp);
4545/* check whether there are signals to handle, process any found */
4646extern int frr_sigevent_process (void );
4747
48+ /* Ensure we don't handle "application-type" signals on a secondary thread by
49+ * blocking these signals when creating threads
50+ *
51+ * NB: SIGSEGV, SIGABRT, etc. must be allowed on all threads or we get no
52+ * crashlogs. Since signals vary a little bit between platforms, below is a
53+ * list of known things to go to the main thread. Any unknown signals should
54+ * stay thread-local.
55+ */
56+ static inline void frr_sigset_add_mainonly (sigset_t * blocksigs )
57+ {
58+ /* signals we actively handle */
59+ sigaddset (blocksigs , SIGHUP );
60+ sigaddset (blocksigs , SIGINT );
61+ sigaddset (blocksigs , SIGTERM );
62+ sigaddset (blocksigs , SIGUSR1 );
63+
64+ /* signals we don't actively use but that semantically belong */
65+ sigaddset (blocksigs , SIGUSR2 );
66+ sigaddset (blocksigs , SIGQUIT );
67+ sigaddset (blocksigs , SIGCHLD );
68+ sigaddset (blocksigs , SIGPIPE );
69+ sigaddset (blocksigs , SIGTSTP );
70+ sigaddset (blocksigs , SIGTTIN );
71+ sigaddset (blocksigs , SIGTTOU );
72+ sigaddset (blocksigs , SIGWINCH );
73+ }
74+
4875#ifdef __cplusplus
4976}
5077#endif
0 commit comments