aboutsummaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-02-04 13:23:15 +0000
committerOmar Polo <op@omarpolo.com>2021-02-04 13:23:15 +0000
commitca21e1004303c6ccff7713813ab5238426414d8f (patch)
treec03fb04ed6d9de1faaec02c382dc86909ac89b2c /utils.c
parent1e3ef7ab4f803b6309fcddc11dc23ecc5f33be27 (diff)
reload configuration on SIGHUP
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index c32ecb8..6254ded 100644
--- a/utils.c
+++ b/utils.c
@@ -19,6 +19,24 @@
#include "gmid.h"
+static sigset_t set;
+
+void
+block_signals(void)
+{
+ sigset_t new;
+
+ sigemptyset(&new);
+ sigaddset(&new, SIGHUP);
+ sigprocmask(SIG_BLOCK, &new, &set);
+}
+
+void
+unblock_signals(void)
+{
+ sigprocmask(SIG_SETMASK, &set, NULL);
+}
+
int
starts_with(const char *str, const char *prefix)
{
@@ -80,3 +98,13 @@ absolutify_path(const char *path)
free(wd);
return r;
}
+
+char *
+xstrdup(const char *s)
+{
+ char *d;
+
+ if ((d = strdup(s)) == NULL)
+ err(1, "strdup");
+ return d;
+}