]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
main: Cleanly quit on SIGTERM
authorHans de Goede <hdegoede@redhat.com>
Tue, 30 Mar 2021 11:35:04 +0000 (13:35 +0200)
committerHans de Goede <hdegoede@redhat.com>
Tue, 6 Apr 2021 11:15:05 +0000 (13:15 +0200)
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>
src/main.c

index dd4843d5de2401a30d6f5d7221ce0c927ee45044..0cee985ef53bc33b42aef6c69879055437100dc7 100644 (file)
@@ -2055,6 +2055,16 @@ on_crash (int signum)
         raise (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)
 {
@@ -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) {