]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: dispatch SIGTERM/SIGINT with a low priority
authorLennart Poettering <lennart@poettering.net>
Tue, 10 Nov 2015 15:53:00 +0000 (16:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 10 Nov 2015 16:36:52 +0000 (17:36 +0100)
Let's make sure to process all queued log data before exiting, so that
we don't unnecessary lose messages when shutting down.

https://github.com/systemd/systemd/pull/1812#issuecomment-155149871

src/journal/journald-server.c

index f0d3a26372dff0307753f9b64150fc296ced8b4a..36fe739073eedeba8e54f83f460bb7bd1d5ea07a 100644 (file)
@@ -1296,10 +1296,22 @@ static int setup_signals(Server *s) {
         if (r < 0)
                 return r;
 
+        /* Let's process SIGTERM late, so that we flush all queued
+         * messages to disk before we exit */
+        r = sd_event_source_set_priority(s->sigterm_event_source, SD_EVENT_PRIORITY_NORMAL+20);
+        if (r < 0)
+                return r;
+
+        /* When journald is invoked on the terminal (when debugging),
+         * it's useful if C-c is handled equivalent to SIGTERM. */
         r = sd_event_add_signal(s->event, &s->sigint_event_source, SIGINT, dispatch_sigterm, s);
         if (r < 0)
                 return r;
 
+        r = sd_event_source_set_priority(s->sigint_event_source, SD_EVENT_PRIORITY_NORMAL+20);
+        if (r < 0)
+                return r;
+
         return 0;
 }