diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-15 16:53:13 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-12-15 20:52:28 +0100 |
commit | a70c72a0463a86ef952346304afe474add0302cf (patch) | |
tree | 134f1edef5678ce4931d8bdce8397edf4181ce2a /src | |
parent | 5a2e0c6257a49a8a1d6b60b33c766f4ca96ade54 (diff) | |
download | systemd-a70c72a0463a86ef952346304afe474add0302cf.tar.gz systemd-a70c72a0463a86ef952346304afe474add0302cf.tar.bz2 systemd-a70c72a0463a86ef952346304afe474add0302cf.zip |
main: slightly rearrange serialization fdset, and logging/console setup
Let's merge two if blocks, and move log_close()/log_open() out of the
testing codepath, as there's no reason to have it there.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/core/main.c b/src/core/main.c index 66270d4e0d..27a4ebc59e 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2408,11 +2408,12 @@ int main(int argc, char *argv[]) { /* Move out of the way, so that we won't block unmounts */ assert_se(chdir("/") == 0); - /* Close logging fds, in order not to confuse fdset below */ - log_close(); - - /* Remember open file descriptors for later deserialization */ if (arg_action == ACTION_RUN) { + + /* Close logging fds, in order not to confuse fdset below */ + log_close(); + + /* Remember open file descriptors for later deserialization */ r = fdset_new_fill(&fds); if (r < 0) { log_emergency_errno(r, "Failed to allocate fd set: %m"); @@ -2424,27 +2425,23 @@ int main(int argc, char *argv[]) { if (arg_serialization) assert_se(fdset_remove(fds, fileno(arg_serialization)) >= 0); - if (arg_system) + if (arg_system) { /* Become a session leader if we aren't one yet. */ setsid(); - } - /* Reset the console, but only if this is really init and we - * are freshly booted */ - if (arg_system && arg_action == ACTION_RUN) { + /* If we are init, we connect stdin/stdout/stderr to /dev/null and make sure we don't have a + * controlling tty. */ + release_terminal(); - /* If we are init, we connect stdin/stdout/stderr to - * /dev/null and make sure we don't have a controlling - * tty. */ - release_terminal(); + /* Reset the console, but only if this is really init and we are freshly booted */ + if (getpid_cached() == 1 && !skip_setup) + console_setup(); + } - if (getpid_cached() == 1 && !skip_setup) - console_setup(); + /* Open the logging devices, if possible and necessary */ + log_open(); } - /* Open the logging devices, if possible and necessary */ - log_open(); - if (arg_show_status == _SHOW_STATUS_UNSET) arg_show_status = SHOW_STATUS_YES; |