summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2016-06-20 21:45:28 +0200
committerFranck Bui <fbui@suse.com>2016-06-22 08:29:02 +0200
commit3a18b60489504056f9b0b1a139439cbfa60a87e1 (patch)
tree8fbc6b165fec3f0a9cc5ce41215b39b3a872e2e2
parent32391275c02715f76232128c49b19bb619cd9463 (diff)
pid1: initialize status color mode after setting up TERM
Also we had to connect PID's stdio to null later since colors_enabled() assume that stdout is connected to the console.
-rw-r--r--src/core/main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 0a09ff514a..6124a984c3 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1382,7 +1382,6 @@ int main(int argc, char *argv[]) {
saved_argv = argv;
saved_argc = argc;
- log_show_color(colors_enabled());
log_set_upgrade_syslog_to_journal(true);
/* Disable the umask logic */
@@ -1393,7 +1392,6 @@ int main(int argc, char *argv[]) {
/* Running outside of a container as PID 1 */
arg_system = true;
- make_null_stdio();
log_set_target(LOG_TARGET_KMSG);
log_open();
@@ -1511,12 +1509,19 @@ int main(int argc, char *argv[]) {
/* We expect the environment to be set correctly if run inside a
* container. */
- if (arg_system && detect_container() <= 0)
+ if (arg_system && detect_container() <= 0) {
if (fixup_environment() < 0) {
error_message = "Failed to fix up PID1 environment";
goto finish;
}
+ /* Try to figure out if we can use colors with the console. No
+ * need to do that for user instances since they never log
+ * into the console. */
+ log_show_color(colors_enabled());
+ make_null_stdio();
+ }
+
/* Initialize default unit */
r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET);
if (r < 0) {