From: Lennart Poettering Date: Tue, 20 Nov 2018 12:16:48 +0000 (+0100) Subject: main: don't freeze PID 1 in containers, exit with non-zero instead X-Git-Tag: v240~261^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10853%2Fhead;p=thirdparty%2Fsystemd.git main: don't freeze PID 1 in containers, exit with non-zero instead After all we have a nice way to propagate total failures, hence let's use it. --- diff --git a/src/core/main.c b/src/core/main.c index 5272df3e3f1..9469512d4eb 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -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;