]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
main: don't freeze PID 1 in containers, exit with non-zero instead 10853/head
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Nov 2018 12:16:48 +0000 (13:16 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 Nov 2018 16:04:07 +0000 (17:04 +0100)
After all we have a nice way to propagate total failures, hence let's
use it.

src/core/main.c

index 5272df3e3f13ba8bb5b3a84f280578521cb3480f..9469512d4eb66bdba6c801a821e4c2d754d1f778 100644 (file)
@@ -130,7 +130,14 @@ static uint64_t arg_default_tasks_max = UINT64_MAX;
 static sd_id128_t arg_machine_id = {};
 static EmergencyAction arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE;
 
-_noreturn_ static void freeze_or_reboot(void) {
+_noreturn_ static void freeze_or_exit_or_reboot(void) {
+
+        /* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the
+         * container manager, and thus inform it that something went wrong. */
+        if (detect_container() > 0) {
+                log_emergency("Exiting PID 1...");
+                exit(EXIT_EXCEPTION);
+        }
 
         if (arg_crash_reboot) {
                 log_notice("Rebooting in 10s...");
@@ -238,7 +245,7 @@ _noreturn_ static void crash(int sig) {
                 }
         }
 
-        freeze_or_reboot();
+        freeze_or_exit_or_reboot();
 }
 
 static void install_crash_handler(void) {
@@ -2622,8 +2629,8 @@ finish:
                 if (error_message)
                         manager_status_printf(NULL, STATUS_TYPE_EMERGENCY,
                                               ANSI_HIGHLIGHT_RED "!!!!!!" ANSI_NORMAL,
-                                              "%s, freezing.", error_message);
-                freeze_or_reboot();
+                                              "%s.", error_message);
+                freeze_or_exit_or_reboot();
         }
 
         return retval;