summaryrefslogtreecommitdiff
path: root/lib/thread.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-09-21 16:02:06 -0400
committerMark Stapp <mjs@voltanet.io>2020-10-28 16:31:54 -0400
commit1543c387be3bd45a68ef1382f07234cd71cac7de (patch)
tree68a6cd46c16f3c3c9a5d1ad6b1020ea76f46567a /lib/thread.c
parent976c5cc134bb96f309479d281d771d70dbe41f13 (diff)
lib: add debug output for signal mask
Add an api that debugs the signals in a sigset. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/thread.c')
-rw-r--r--lib/thread.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/thread.c b/lib/thread.c
index 1765de9573..01bb0e670b 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -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);
+}