diff mbox

[6/6] kvm tools: Introduce a helper to show the blocked signals

Message ID 1308156491-18488-6-git-send-email-asias.hejun@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Asias He June 15, 2011, 4:48 p.m. UTC
This helper shows  the blocked signals of the calling thread.

Signed-off-by: Asias He <asias.hejun@gmail.com>
---
 tools/kvm/include/kvm/util.h |    1 +
 tools/kvm/util.c             |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/include/kvm/util.h b/tools/kvm/include/kvm/util.h
index 95d86b9..6fd0f7e 100644
--- a/tools/kvm/include/kvm/util.h
+++ b/tools/kvm/include/kvm/util.h
@@ -68,6 +68,7 @@  static inline const char *skip_prefix(const char *str, const char *prefix)
 	return strncmp(str, prefix, len) ? NULL : str + len;
 }
 
+void sig_prt_blocked(const char *str);
 int sig_block(int n);
 
 #endif /* KVM__UTIL_H */
diff --git a/tools/kvm/util.c b/tools/kvm/util.c
index 204230e..2f2dcf6 100644
--- a/tools/kvm/util.c
+++ b/tools/kvm/util.c
@@ -101,6 +101,23 @@  size_t strlcat(char *dest, const char *src, size_t count)
 	return res;
 }
 
+void sig_prt_blocked(const char *str)
+{
+	sigset_t sigset;
+	int i;
+
+	printf("-> %s : Blocked sig: ", str);
+
+	if (pthread_sigmask(0, NULL, &sigset) < 0)
+		return;
+	for (i = 1; i < _NSIG; i++) {
+		if (sigismember(&sigset, i))
+			printf("%d ", i);
+	}
+	printf("\n");
+
+}
+
 int sig_block(int n)
 {
 	sigset_t sigset;