Commit 897b281e authored by louiz’'s avatar louiz’

Avoid some potential race conditions by blocking the signals we manage

They are atomically unblocked in the ppoll/epoll_pwait calls, avoiding any
race condition on the check of the “stop” or “reload” booleans.
parent 54f96deb
louloulibs @ 0f3c1183
Subproject commit 89398b5d886744c3812b65195308cae57eca2b53
Subproject commit 0f3c1183e2bf0941ae2bffd3f31577bce4f3001c
......@@ -99,9 +99,19 @@ int main(int ac, char** av)
if (hostname.empty())
return config_help("hostname");
// Block the signals we want to manage. They will be unblocked only during
// the epoll_pwait or ppoll calls. This avoids some race conditions,
// explained in man 2 pselect on linux
sigset_t mask;
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
sigaddset(&mask, SIGUSR1);
sigaddset(&mask, SIGUSR2);
sigprocmask(SIG_BLOCK, &mask, nullptr);
// Install the signals used to exit the process cleanly, or reload the
// config
sigset_t mask;
struct sigaction on_sigint;
on_sigint.sa_sigaction = &sigint_handler;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment