diff options
author | Omar Polo <op@omarpolo.com> | 2021-02-04 13:23:15 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-02-04 13:23:15 +0000 |
commit | ca21e1004303c6ccff7713813ab5238426414d8f (patch) | |
tree | c03fb04ed6d9de1faaec02c382dc86909ac89b2c /utils.c | |
parent | 1e3ef7ab4f803b6309fcddc11dc23ecc5f33be27 (diff) |
reload configuration on SIGHUP
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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; +} |