shutdown: explicitly set a log target in shutdown.c

We used to set this, but this was dropped when shutdown got taught to
get the target passed in from the regular PID 1. Let's readd this to
make things more explanatory, and cover all grounds, since after all the
target passed is in theory an optional part of the protocol between the
regular PID 1 and the shutdown PID 1.
This commit is contained in:
Lennart Poettering
2018-02-22 00:33:12 +01:00
parent d405394c5c
commit e18805fbd0
+9 -6
View File
@@ -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