From a6ccfb780a2754a66af3af289932dd47e593e348 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 29 May 2026 22:26:37 +0200 Subject: [PATCH] hostnamed: handle SIGRTMIN+18 and memory pressure Wire up the usual SIGRTMIN+18 control signal handler and a memory pressure event source in hostnamed's event loop, like our other long-running daemons, so it reacts to memory pressure (e.g. by trimming its heap) and supports the common debug/control commands. Watchdog support via sd_event_set_watchdog() was already in place. --- src/hostname/hostnamed.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 42fc050f40..5f7496f7cf 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -17,6 +17,7 @@ #include "bus-object.h" #include "bus-polkit.h" #include "bus-util.h" +#include "common-signal.h" #include "constants.h" #include "daemon-util.h" #include "device-private.h" @@ -2674,6 +2675,14 @@ static int run(int argc, char *argv[]) { if (r < 0) return log_error_errno(r, "Failed to install SIGINT/SIGTERM handlers: %m"); + r = sd_event_add_signal(context.event, /* ret= */ NULL, (SIGRTMIN+18)|SD_EVENT_SIGNAL_PROCMASK, sigrtmin18_handler, /* userdata= */ NULL); + if (r < 0) + return log_error_errno(r, "Failed to install SIGRTMIN+18 handler: %m"); + + r = sd_event_add_memory_pressure(context.event, /* ret= */ NULL, /* callback= */ NULL, /* userdata= */ NULL); + if (r < 0) + log_debug_errno(r, "Failed to allocate memory pressure event source, ignoring: %m"); + r = connect_bus(&context); if (r < 0) return r;