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_ */