summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2021-03-30 13:35:04 +0200
committerHans de Goede <hdegoede@redhat.com>2021-04-06 13:15:05 +0200
commiteb5227b47485183174f98807e15d224ecde25217 (patch)
treeeb58a6eaab12d23a487feedfe2f40284ce53c74b /src
parent156ae7437efaf32825d92943577f24914cf56cec (diff)
main: Cleanly quit on SIGTERM
Now that we are no longer unconditionally opting out of getting terminated, we get send a SIGTERM when transitioning from the rootfs back to the initrd on poweroff/reboot. Catch this SIGTERM and then exit cleanly by calling the on_quit handler, besides exiting cleanly being the right thing to do, this will also allow the boot-splash to go idle, so that it can cleanly finish the end-animation. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/main.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index dd4843d5..0cee985e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2056,6 +2056,16 @@ on_crash (int signum)
}
static void
+on_term_signal (state_t *state)
+{
+ bool retain_splash = false;
+
+ ply_trace ("received SIGTERM");
+
+ on_quit (state, retain_splash, ply_trigger_new (NULL));
+}
+
+static void
write_pid_file (const char *filename)
{
FILE *fp;
@@ -2223,6 +2233,10 @@ main (int argc,
access ("/etc/initrd-release", F_OK) >= 0)
argv[0][0] = '@';
+ /* Catch SIGTERM for clean shutdown on poweroff/reboot */
+ ply_event_loop_watch_signal (state.loop, SIGTERM,
+ (ply_event_handler_t) on_term_signal, &state);
+
state.boot_server = start_boot_server (&state);
if (state.boot_server == NULL) {