]> 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, 28 Oct 2020 20:31:54 +0000 (16:31 -0400)
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 1765de957304260efd3d833e5049aca8c447c234..01bb0e670be51e5223cc9fa27f8642fcafe80812 100644 (file)
@@ -1703,3 +1703,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 e2b7763c514d572c6a45eeaf18339cfa009e1040..682a17b9f302cac88308ea4128d38145030d1e3b 100644 (file)
@@ -230,6 +230,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