From a4beb74fa5584ea5704bca0ddeb6937bbf4be572 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 8 Sep 2014 15:23:59 +0300 Subject: [PATCH] posix: add signalfd wrappers --- core/posix.hh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/posix.hh b/core/posix.hh index 7fcbdb59be..eb27cdaab1 100644 --- a/core/posix.hh +++ b/core/posix.hh @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include inline void throw_system_error_on(bool condition); @@ -70,6 +72,11 @@ public: throw_system_error_on(fd == -1); return file_desc(fd); } + static file_desc signalfd(const sigset_t& mask, int flags) { + int fd = ::signalfd(-1, &mask, flags); + throw_system_error_on(fd == -1); + return file_desc(fd); + } file_desc accept(sockaddr& sa, socklen_t& sl, int flags = 0) { auto ret = ::accept4(_fd, &sa, &sl, flags); throw_system_error_on(ret == -1); @@ -178,4 +185,12 @@ void throw_kernel_error(T r) { } } +inline +sigset_t make_sigset_mask(int signo) { + sigset_t set; + sigemptyset(&set); + sigaddset(&set, signo); + return set; +} + #endif /* FILE_DESC_HH_ */