diff --git a/src/core/shutdown.c b/src/core/shutdown.c index 95eafccc7b..0326a7808d 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -276,15 +276,18 @@ int main(int argc, char *argv[]) { static const char* const dirs[] = {SYSTEM_SHUTDOWN_PATH, NULL}; char *watchdog_device; + /* The log target defaults to console, but the original systemd process will pass its log target in through a + * command line argument, which will override this default. Also, ensure we'll never log to the journal or + * syslog, as these logging daemons are either already dead or will die very soon. */ + + log_set_target(LOG_TARGET_CONSOLE); + log_set_prohibit_ipc(true); log_parse_environment(); + r = parse_argv(argc, argv); if (r < 0) goto error; - /* journald will die if not gone yet. The log target defaults - * to console, but may have been changed by command line options. */ - - log_set_prohibit_ipc(true); log_open(); umask(0022); @@ -306,8 +309,8 @@ int main(int argc, char *argv[]) { else if (streq(arg_verb, "exit")) cmd = 0; /* ignored, just checking that arg_verb is valid */ else { - r = -EINVAL; log_error("Unknown action '%s'.", arg_verb); + r = -EINVAL; goto error; } @@ -324,7 +327,7 @@ int main(int argc, char *argv[]) { } /* Lock us into memory */ - mlockall(MCL_CURRENT|MCL_FUTURE); + (void) mlockall(MCL_CURRENT|MCL_FUTURE); /* Synchronize everything that is not written to disk yet at this point already. This is a good idea so that * slow IO is processed here already and the final process killing spree is not impacted by processes