X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fmain.c;h=2e6ccfaa30d37f3e7a74234f4722cb296a150b66;hp=f1fa5691120ca26f9002b7f67de231bf1b9e638e;hb=35df8f27fae82c6f9e83d750ffa5e54733b16cf2;hpb=173a8d04fc3535b571fe4a0d4715c18be315a43a diff --git a/src/main.c b/src/main.c index f1fa56911..2e6ccfaa3 100644 --- a/src/main.c +++ b/src/main.c @@ -66,6 +66,7 @@ static bool arg_show_status = true; static bool arg_sysv_console = true; static bool arg_mount_auto = true; static bool arg_swap_auto = true; +static char *arg_console = NULL; static FILE* serialization = NULL; @@ -335,6 +336,26 @@ static int parse_proc_cmdline_word(const char *word) { "systemd.log_color=0|1 Highlight important log messages\n" "systemd.log_location=0|1 Include code location in log messages\n"); + } else if (startswith(word, "console=")) { + const char *k; + size_t l; + char *w = NULL; + + k = word + 8; + l = strcspn(k, ","); + + /* Ignore the console setting if set to a VT */ + if (l < 4 || + !startswith(k, "tty") || + k[3+strspn(k+3, "0123456789")] != 0) { + + if (!(w = strndup(k, l))) + return -ENOMEM; + } + + free(arg_console); + arg_console = w; + } else if (streq(word, "quiet")) { arg_show_status = false; arg_sysv_console = false; @@ -855,7 +876,7 @@ fail: int main(int argc, char *argv[]) { Manager *m = NULL; - int r, retval = 1; + int r, retval = EXIT_FAILURE; FDSet *fds = NULL; bool reexecute = false; @@ -916,10 +937,10 @@ int main(int argc, char *argv[]) { goto finish; } else if (arg_action == ACTION_DUMP_CONFIGURATION_ITEMS) { unit_dump_config_items(stdout); - retval = 0; + retval = EXIT_SUCCESS; goto finish; } else if (arg_action == ACTION_DONE) { - retval = 0; + retval = EXIT_SUCCESS; goto finish; } @@ -993,6 +1014,9 @@ int main(int argc, char *argv[]) { m->mount_auto = arg_mount_auto; m->swap_auto = arg_swap_auto; + if (arg_console) + manager_set_console(m, arg_console); + if ((r = manager_startup(m, serialization, fds)) < 0) log_error("Failed to fully start up daemon: %s", strerror(-r)); @@ -1048,7 +1072,7 @@ int main(int argc, char *argv[]) { if (arg_action == ACTION_TEST) { printf("-> By jobs:\n"); manager_dump_jobs(m, stdout, "\t"); - retval = 0; + retval = EXIT_SUCCESS; goto finish; } } @@ -1062,7 +1086,7 @@ int main(int argc, char *argv[]) { switch (m->exit_code) { case MANAGER_EXIT: - retval = 0; + retval = EXIT_SUCCESS; log_debug("Exit."); goto finish; @@ -1090,9 +1114,12 @@ finish: manager_free(m); free(arg_default_unit); + free(arg_console); dbus_shutdown(); + label_finish(); + if (reexecute) { const char *args[15]; unsigned i = 0; @@ -1157,7 +1184,5 @@ finish: if (getpid() == 1) freeze(); - label_finish(); - return retval; }