aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2020-05-13 17:08:54 +0200
committerDavid Oberhollenzer <goliath@infraroot.at>2020-05-13 17:08:54 +0200
commit9084f3862973aa5eccfafe51c6682a6aef123d4d (patch)
treefcd0810e34a1c9b97aa796ebc114fb605f916162 /lib
parentdd0007f9dcb850806cb62ecc705c35789e12f175 (diff)
Add utility functions for clearing/setting signal mask
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/Makemodule.am1
-rw-r--r--lib/include/util.h26
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index fa8789b..836bd4d 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -1,6 +1,7 @@
libinit_a_SOURCES = lib/init/delsvc.c lib/init/svcmap.c lib/init/rdsvc.c
libinit_a_SOURCES += lib/init/svcscan.c lib/init/del_svc_list.c
libinit_a_SOURCES += lib/init/svc_tsort.c lib/include/service.h
+libinit_a_SOURCES += lib/include/util.h
libinit_a_CPPFLAGS = $(AM_CPPFLAGS)
libinit_a_CFLAGS = $(AM_CFLAGS)
diff --git a/lib/include/util.h b/lib/include/util.h
new file mode 100644
index 0000000..884eeab
--- /dev/null
+++ b/lib/include/util.h
@@ -0,0 +1,26 @@
+#ifndef UTIL_H
+#define UTIL_H
+
+#include <signal.h>
+
+static inline void cli(sigset_t *old_mask)
+{
+ sigset_t mask;
+
+ sigfillset(&mask);
+ sigprocmask(SIG_SETMASK, &mask, old_mask);
+}
+
+static inline void sti(const sigset_t *old_mask)
+{
+ sigset_t mask;
+
+ if (old_mask == NULL) {
+ sigemptyset(&mask);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
+ } else {
+ sigprocmask(SIG_SETMASK, old_mask, NULL);
+ }
+}
+
+#endif /* UTIL_H */