diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-15 17:13:36 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-12-15 20:52:28 +0100 |
commit | 2e51b31caf683409cfa953f5bbefcc72d9ffb016 (patch) | |
tree | 2e836ea26994d0d941fedfc67b9f0324347fd1e6 /src | |
parent | efeb853fbd03aaa63d657623139b30581d386096 (diff) | |
download | systemd-2e51b31caf683409cfa953f5bbefcc72d9ffb016.tar.gz systemd-2e51b31caf683409cfa953f5bbefcc72d9ffb016.tar.bz2 systemd-2e51b31caf683409cfa953f5bbefcc72d9ffb016.zip |
main: split out code that sets up the console/terminal and stuff
More refactoring to make main() more digestable.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/core/main.c b/src/core/main.c index 8dd4da1203..06fe372631 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2235,6 +2235,23 @@ static int collect_fds(FDSet **ret_fds, const char **ret_error_message) { return 0; } +static void setup_console_terminal(bool skip_setup) { + + if (!arg_system) + return; + + /* Become a session leader if we aren't one yet. */ + (void) setsid(); + + /* If we are init, we connect stdin/stdout/stderr to /dev/null and make sure we don't have a controlling + * tty. */ + (void) release_terminal(); + + /* Reset the console, but only if this is really init and we are freshly booted */ + if (getpid_cached() == 1 && !skip_setup) + (void) console_setup(); +} + int main(int argc, char *argv[]) { Manager *m = NULL; int r, retval = EXIT_FAILURE; @@ -2439,18 +2456,8 @@ int main(int argc, char *argv[]) { if (r < 0) goto finish; - if (arg_system) { - /* Become a session leader if we aren't one yet. */ - setsid(); - - /* 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(); - } + /* Give up any control of the console, but make sure its initialized. */ + setup_console_terminal(skip_setup); /* Open the logging devices, if possible and necessary */ log_open(); |