Skip to content

Commit 3a18b60

Browse files
committed
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.
1 parent 3239127 commit 3a18b60

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core/main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,6 @@ int main(int argc, char *argv[]) {
13821382
saved_argv = argv;
13831383
saved_argc = argc;
13841384

1385-
log_show_color(colors_enabled());
13861385
log_set_upgrade_syslog_to_journal(true);
13871386

13881387
/* Disable the umask logic */
@@ -1393,7 +1392,6 @@ int main(int argc, char *argv[]) {
13931392

13941393
/* Running outside of a container as PID 1 */
13951394
arg_system = true;
1396-
make_null_stdio();
13971395
log_set_target(LOG_TARGET_KMSG);
13981396
log_open();
13991397

@@ -1511,12 +1509,19 @@ int main(int argc, char *argv[]) {
15111509

15121510
/* We expect the environment to be set correctly if run inside a
15131511
* container. */
1514-
if (arg_system && detect_container() <= 0)
1512+
if (arg_system && detect_container() <= 0) {
15151513
if (fixup_environment() < 0) {
15161514
error_message = "Failed to fix up PID1 environment";
15171515
goto finish;
15181516
}
15191517

1518+
/* Try to figure out if we can use colors with the console. No
1519+
* need to do that for user instances since they never log
1520+
* into the console. */
1521+
log_show_color(colors_enabled());
1522+
make_null_stdio();
1523+
}
1524+
15201525
/* Initialize default unit */
15211526
r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET);
15221527
if (r < 0) {

0 commit comments

Comments
 (0)