]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add debug output for signal mask
authorMark Stapp <mjs@voltanet.io>
Mon, 21 Sep 2020 20:02:06 +0000 (16:02 -0400)
committerMark Stapp <mjs@voltanet.io>
Wed, 3 Mar 2021 17:47:22 +0000 (12:47 -0500)
Add an api that debugs the signals in a sigset.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
lib/thread.c
lib/thread.h

index 19e482728385766df863f8a22e029fecb285e930..f83cbea68a9c29d8a53283a0c6663b266ef67427 100644 (file)
@@ -1656,3 +1656,49 @@ void funcname_thread_execute(struct thread_master *m,
        /* Give back or free thread. */
        thread_add_unuse(m, thread);
 }
+
+/* Debug signal mask - if 'sigs' is NULL, use current effective mask. */
+void debug_signals(const sigset_t *sigs)
+{
+       int i, found;
+       sigset_t tmpsigs;
+       char buf[300];
+
+       /*
+        * We're only looking at the non-realtime signals here, so we need
+        * some limit value. Platform differences mean at some point we just
+        * need to pick a reasonable value.
+        */
+#if defined SIGRTMIN
+#  define LAST_SIGNAL SIGRTMIN
+#else
+#  define LAST_SIGNAL 32
+#endif
+
+
+       if (sigs == NULL) {
+               sigemptyset(&tmpsigs);
+               pthread_sigmask(SIG_BLOCK, NULL, &tmpsigs);
+               sigs = &tmpsigs;
+       }
+
+       found = 0;
+       buf[0] = '\0';
+
+       for (i = 0; i < LAST_SIGNAL; i++) {
+               char tmp[20];
+
+               if (sigismember(sigs, i) > 0) {
+                       if (found > 0)
+                               strlcat(buf, ",", sizeof(buf));
+                       snprintf(tmp, sizeof(tmp), "%d", i);
+                       strlcat(buf, tmp, sizeof(buf));
+                       found++;
+               }
+       }
+
+       if (found == 0)
+               snprintf(buf, sizeof(buf), "<none>");
+
+       zlog_debug("%s: %s", __func__, buf);
+}
index c22b2105cd43969215d4a597fc29dcc3ed670e3f..55ddac405947afc486ec0e9fa9abed05e9cbf1c0 100644 (file)
@@ -233,6 +233,9 @@ extern pthread_key_t thread_current;
 extern char *thread_timer_to_hhmmss(char *buf, int buf_size,
                struct thread *t_timer);
 
+/* Debug signal mask */
+void debug_signals(const sigset_t *sigs);
+
 #ifdef __cplusplus
 }
 #endif