From: Michael Tremer Date: Mon, 6 Oct 2025 14:29:16 +0000 (+0000) Subject: daemon: Mask SIGCHLD X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08845ea569573e5491885af3a3c9f3e59c9f7a57;p=telemetry.git daemon: Mask SIGCHLD Signed-off-by: Michael Tremer --- diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 3c80bc0..7405061 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -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)