chiark / gitweb /
Prep v229: Add missing fixes from upstream [1/6] src/basic
[elogind.git] / src / basic / signal-util.h
index 3f22fd46e76a109e6c8e517faecd0cb8e08f0b16..7013c51a3d9aaa4385ec3321bd405b6a107f5e25 100644 (file)
@@ -40,5 +40,17 @@ int signal_from_string(const char *s) _pure_;
 
 int signal_from_string_try_harder(const char *s);
 #if 0 /// UNNEEDED by elogind
+
 void nop_signal_handler(int sig);
 #endif // 0
+
+static inline void block_signals_reset(sigset_t *ss) {
+        assert_se(sigprocmask(SIG_SETMASK, ss, NULL) >= 0);
+}
+
+#define BLOCK_SIGNALS(...)                                              \
+        _cleanup_(block_signals_reset) sigset_t _saved_sigset = ({      \
+                sigset_t t;                                             \
+                assert_se(sigprocmask_many(SIG_BLOCK, &t, __VA_ARGS__, -1) >= 0); \
+                t;                                                      \
+        })