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.
This commit is contained in:
Lennart Poettering 2018-11-20 13:16:48 +01:00
parent bb85a58208
commit bb25977244
1 changed files with 11 additions and 4 deletions

View 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;