static int terminate = 0;
static struct faultd_config config;
-int sigint_handler(sd_event_source *s, const struct signalfd_siginfo *si,
- void *userdata);
-
-int sigint_handler(sd_event_source *s,
+static int signal_handler(sd_event_source *s,
const struct signalfd_siginfo *si,
void *userdata)
{
/* sd_bus_attach_event(bus, loop, SD_EVENT_PRIORITY_NORMAL); */
sigemptyset(&ss);
sigaddset(&ss, SIGINT);
+ sigaddset(&ss, SIGTERM);
rc = sigprocmask(SIG_BLOCK, &ss, NULL);
- rc = sd_event_add_signal(loop, NULL, SIGINT, sigint_handler, loop);
+ if (rc < 0) {
+ log_error("Failed to change signal mask %d.", rc);
+ return -1;
+ }
+
+ rc = sd_event_add_signal(loop, NULL, SIGINT, signal_handler, loop);
+ if (rc < 0) {
+ log_error("Failed to register SIGINT handler %d.", rc);
+ return -1;
+ }
+
+ rc = sd_event_add_signal(loop, NULL, SIGTERM, signal_handler, loop);
+ if (rc < 0) {
+ log_error("Failed to register SIGTERM handler %d.", rc);
+ return -1;
+ }
rc = faultd_modules_init(loop, &config);
if (rc < 0) {