diff options
author | Mark Stapp <mjs@voltanet.io> | 2020-09-21 22:02:06 +0200 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2020-10-28 21:31:54 +0100 |
commit | 1543c387be3bd45a68ef1382f07234cd71cac7de (patch) | |
tree | 68a6cd46c16f3c3c9a5d1ad6b1020ea76f46567a /lib | |
parent | lib: add sigevent_check api (diff) | |
download | frr-1543c387be3bd45a68ef1382f07234cd71cac7de.tar.xz frr-1543c387be3bd45a68ef1382f07234cd71cac7de.zip |
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')
-rw-r--r-- | lib/thread.c | 46 | ||||
-rw-r--r-- | lib/thread.h | 3 |
2 files changed, 49 insertions, 0 deletions
diff --git a/lib/thread.c b/lib/thread.c index 1765de957..01bb0e670 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); +} diff --git a/lib/thread.h b/lib/thread.h index e2b7763c5..682a17b9f 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -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 |