summaryrefslogtreecommitdiff
path: root/src/basic/signal-util.h
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2016-01-27 13:35:18 +0100
committerDaniel Mack <github@zonque.org>2016-01-27 13:35:18 +0100
commitfdb4ee00f022863ceee923b196f9c6dd536db9e2 (patch)
tree647aae3aa21c2e22073fc895f39a2c171e052a99 /src/basic/signal-util.h
parent1cdc94482302cca88e0a7282bbc161c1d77c381c (diff)
parenta464cf80110f0c7424f688ffaa4ec0a8a19f9720 (diff)
Merge pull request #2445 from poettering/various-fixes
A number of fixes
Diffstat (limited to 'src/basic/signal-util.h')
-rw-r--r--src/basic/signal-util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h
index e7393e2dac..5d94d1c363 100644
--- a/src/basic/signal-util.h
+++ b/src/basic/signal-util.h
@@ -41,3 +41,14 @@ int signal_from_string(const char *s) _pure_;
int signal_from_string_try_harder(const char *s);
void nop_signal_handler(int sig);
+
+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; \
+ })