]> git.ipfire.org Git - telemetry.git/commitdiff
daemon: Mask SIGCHLD
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 Oct 2025 14:29:16 +0000 (14:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 Oct 2025 14:29:16 +0000 (14:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/daemon.c

index 3c80bc05454d9bfa858ada2896797e71b9188e48..7405061b726c74f3d66522e19963eabdc0728e9a 100644 (file)
@@ -46,6 +46,7 @@ struct collecty_daemon {
                sd_event_source* sigterm;
                sd_event_source* sigint;
                sd_event_source* sighup;
+               sd_event_source* sigchld;
                sd_event_source* init;
                sd_event_source* exit;
        } events;
@@ -119,6 +120,11 @@ static int collecty_daemon_SIGHUP(sd_event_source* source,
        return collecty_queue_flush(self->queue);
 }
 
+static int collecty_daemon_SIGCHLD(sd_event_source* source,
+               const struct signalfd_siginfo* si, void* data) {
+       return 0;
+}
+
 static int collecty_daemon_setup_loop(collecty_daemon* self) {
        int r;
 
@@ -158,6 +164,14 @@ static int collecty_daemon_setup_loop(collecty_daemon* self) {
                return r;
        }
 
+       // Listen for SIGCHLD
+       r = sd_event_add_signal(self->loop, &self->events.sighup,
+                       SIGCHLD|SD_EVENT_SIGNAL_PROCMASK, collecty_daemon_SIGCHLD, self);
+       if (r < 0) {
+               ERROR(self->ctx, "Could not register handling SIGCHLD: %s\n", strerror(-r));
+               return r;
+       }
+
        // Initialize the daemon when the loop starts
        r = sd_event_add_defer(self->loop, &self->events.init,
                        collecty_daemon_init, self);
@@ -178,6 +192,8 @@ static int collecty_daemon_setup_loop(collecty_daemon* self) {
 }
 
 static void collecty_daemon_free(collecty_daemon* self) {
+       if (self->events.sigchld)
+               sd_event_source_unref(self->events.sigchld);
        if (self->events.sigterm)
                sd_event_source_unref(self->events.sigterm);
        if (self->events.sigint)