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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user