Skip to content

Commit

Permalink
journald: dispatch SIGTERM/SIGINT with a low priority
Browse files Browse the repository at this point in the history
Let's make sure to process all queued log data before exiting, so that
we don't unnecessary lose messages when shutting down.

#1812 (comment)
  • Loading branch information
poettering committed Nov 10, 2015
1 parent a4c1800 commit b374689
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/journal/journald-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b374689

Please sign in to comment.