116 sigdelset(hMask, SIGINT);
117 sigdelset(hMask, SIGQUIT);
119 const struct sigaction saShutdown = {
120 .sa_handler =
signalShutdown, .sa_mask = *hMask, .sa_flags = SA_RESTART};
121 const struct sigaction saRotate = {
122 .sa_handler =
signalRotate, .sa_mask = *hMask, .sa_flags = SA_RESTART};
123 const struct sigaction saPause = {
124 .sa_handler =
signalPause, .sa_mask = *hMask, .sa_flags = SA_RESTART};
125 const struct sigaction saUnpause = {
126 .sa_handler =
signalUnpause, .sa_mask = *hMask, .sa_flags = SA_RESTART};
132 sigaction(SIGINT, &saShutdown, NULL);
133 sigaction(SIGQUIT, &saShutdown, NULL);
134 sigaction(SIGRTMIN + 1, &saShutdown, NULL);
137 sigaction(SIGUSR1, &saRotate, NULL);
138 sigaction(SIGHUP, &saRotate, NULL);
139 sigaction(SIGRTMIN + 2, &saRotate, NULL);
146 sigaction(SIGRTMIN + 3, &saPause, NULL);
147 sigaction(SIGRTMIN + 4, &saUnpause, NULL);
165 sigset_t *blocking = calloc(1,
sizeof(sigset_t));
168 sigemptyset(blocking);
169 sigaddset(blocking, SIGINT);
170 sigaddset(blocking, SIGQUIT);
171 sigaddset(blocking, SIGUSR1);
172 sigaddset(blocking, SIGHUP);
173 sigaddset(blocking, SIGRTMIN + 1);
174 sigaddset(blocking, SIGRTMIN + 2);
175 sigaddset(blocking, SIGRTMIN + 3);
176 sigaddset(blocking, SIGRTMIN + 4);
182 pthread_sigmask(SIG_BLOCK, hMask, NULL);
188 pthread_sigmask(SIG_UNBLOCK, hMask, NULL);
void signalHandlersUnblock(void)
Unblock signals that we have handlers for.
sigset_t * signalHandlerMask(void)
Return a signal mask with suitable defaults.
void signalHandlersInstall(void)
Install signal handlers.
void signalHandlersBlock(void)
Block signals that we have handlers for.
void signalShutdown(int signnum)
Set safe shutdown flag.
void signalRotate(int signnum)
Set log rotate flag.
void signalPause(int signnum)
Set logger pause flag.
atomic_bool pauseLog
Pause logging.
atomic_bool rotateNow
Trigger immediate log rotation.
void signalUnpause(int signnum)
Clear logger pause flag.
atomic_bool shutdownFlag
Trigger clean software shutdown.