diff options
author | Omar Polo <op@omarpolo.com> | 2021-03-20 10:43:23 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-03-20 10:43:23 +0000 |
commit | b9c9123b8ecf2bd73498dc7cb0526be73df7ee9e (patch) | |
tree | 1112263c588dab037662af64ee6688e4272a4878 /gmid.c | |
parent | e3d81f49cc4084f6af16a497cf56d15d79d1c1b8 (diff) |
fix signal handling so it works on linux too
it seems that linux calls the signal handlers even when we're waiting
on sigwait for that signal. Work around that.
Diffstat (limited to 'gmid.c')
-rw-r--r-- | gmid.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -38,6 +38,12 @@ struct conf conf; struct tls_config *tlsconf; struct tls *ctx; +static void +dummy_handler(int signo) +{ + return; +} + /* XXX: create recursively */ void mkdirs(const char *path) @@ -494,6 +500,14 @@ main(int argc, char **argv) return 0; } + + /* Linux seems to call the event handlers even when we're + * doing a sigwait. This dummy handlers is here to avoid + * being terminated on SIGHUP, SIGTERM or SIGINFO. */ + signal(SIGHUP, dummy_handler); + signal(SIGINT, dummy_handler); + signal(SIGTERM, dummy_handler); + /* wait a sighup and reload the daemon */ for (;;) { int p[2]; @@ -506,7 +520,6 @@ main(int argc, char **argv) case -1: fatal("fork: %s", strerror(errno)); case 0: - signal(SIGHUP, SIG_IGN); close(p[0]); imsg_init(&exibuf, p[1]); _exit(serve(argc, argv, &exibuf)); |