teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0388-journald-dispatch-SIGTERM-SIGINT-with-a-low-priority.patch

1abbee
From be21e10cf30e66215e986ab900637b32e502a29a Mon Sep 17 00:00:00 2001
1abbee
From: Lennart Poettering <lennart@poettering.net>
1abbee
Date: Tue, 10 Nov 2015 16:53:00 +0100
1abbee
Subject: [PATCH] journald: dispatch SIGTERM/SIGINT with a low priority
1abbee
1abbee
Let's make sure to process all queued log data before exiting, so that
1abbee
we don't unnecessary lose messages when shutting down.
1abbee
1abbee
https://github.com/systemd/systemd/pull/1812#issuecomment-155149871
1abbee
1abbee
Cherry-picked from: b374689c02c681671a3c3c0b0fd3add32386b442
1abbee
Related: #1318994
1abbee
---
1abbee
 src/journal/journald-server.c | 12 ++++++++++++
1abbee
 1 file changed, 12 insertions(+)
1abbee
1abbee
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
c62b8e
index 275224dc99..2b7ecd09ab 100644
1abbee
--- a/src/journal/journald-server.c
1abbee
+++ b/src/journal/journald-server.c
1abbee
@@ -1284,10 +1284,22 @@ static int setup_signals(Server *s) {
1abbee
         if (r < 0)
1abbee
                 return r;
1abbee
 
1abbee
+        /* Let's process SIGTERM late, so that we flush all queued
1abbee
+         * messages to disk before we exit */
1abbee
+        r = sd_event_source_set_priority(s->sigterm_event_source, SD_EVENT_PRIORITY_NORMAL+20);
1abbee
+        if (r < 0)
1abbee
+                return r;
1abbee
+
1abbee
+        /* When journald is invoked on the terminal (when debugging),
1abbee
+         * it's useful if C-c is handled equivalent to SIGTERM. */
1abbee
         r = sd_event_add_signal(s->event, &s->sigint_event_source, SIGINT, dispatch_sigterm, s);
1abbee
         if (r < 0)
1abbee
                 return r;
1abbee
 
1abbee
+        r = sd_event_source_set_priority(s->sigint_event_source, SD_EVENT_PRIORITY_NORMAL+20);
1abbee
+        if (r < 0)
1abbee
+                return r;
1abbee
+
1abbee
         return 0;
1abbee
 }
1abbee