commit b9c9123b8ecf2bd73498dc7cb0526be73df7ee9e from: Omar Polo date: Sat Mar 20 10:43:23 2021 UTC 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. commit - e3d81f49cc4084f6af16a497cf56d15d79d1c1b8 commit + b9c9123b8ecf2bd73498dc7cb0526be73df7ee9e blob - 2d0022cbd86a691c4323c61bb1f64b5f2ae05ffc blob + 47c406181f51956764c9e27ce8075e15312583fb --- gmid.c +++ gmid.c @@ -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));