diff mbox

[1/6] kvm tools: Introduce a helper to block a singal for a thread

Message ID 1308156491-18488-1-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
Signed-off-by: Asias He <asias.hejun@gmail.com>
---
 tools/kvm/include/kvm/util.h |    2 ++
 tools/kvm/util.c             |   13 +++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/include/kvm/util.h b/tools/kvm/include/kvm/util.h
index a9425cc..95d86b9 100644
--- a/tools/kvm/include/kvm/util.h
+++ b/tools/kvm/include/kvm/util.h
@@ -68,4 +68,6 @@  static inline const char *skip_prefix(const char *str, const char *prefix)
 	return strncmp(str, prefix, len) ? NULL : str + len;
 }
 
+int sig_block(int n);
+
 #endif /* KVM__UTIL_H */
diff --git a/tools/kvm/util.c b/tools/kvm/util.c
index 4efbce9..204230e 100644
--- a/tools/kvm/util.c
+++ b/tools/kvm/util.c
@@ -3,6 +3,7 @@ 
  */
 
 #include "kvm/util.h"
+#include <signal.h>
 
 static void report(const char *prefix, const char *err, va_list params)
 {
@@ -99,3 +100,15 @@  size_t strlcat(char *dest, const char *src, size_t count)
 
 	return res;
 }
+
+int sig_block(int n)
+{
+	sigset_t sigset;
+	int ret;
+
+	sigemptyset(&sigset);
+	sigaddset(&sigset, n);
+	ret = pthread_sigmask(SIG_BLOCK, &sigset, NULL);
+
+	return ret;
+}