dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
Blob Blame History Raw
From df5013c79d99848730abe4585dd93f77409a95c0 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 18 Dec 2013 05:07:34 +0100
Subject: [PATCH] log: don't reopen /dev/console each time we call log_open()

Instead, force reopen it only if we really really have to.
---
 src/core/main.c     | 1 +
 src/core/shutdown.c | 1 +
 src/shared/log.c    | 2 --
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/main.c b/src/core/main.c
index 58c3a9e..935762f 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1347,6 +1347,7 @@ int main(int argc, char *argv[]) {
                 /* Running inside a container, as PID 1 */
                 arg_running_as = SYSTEMD_SYSTEM;
                 log_set_target(LOG_TARGET_CONSOLE);
+                log_close_console(); /* force reopen of /dev/console */
                 log_open();
 
                 /* For the later on, see above... */
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index ea02b60..5e0f3ce 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -155,6 +155,7 @@ int main(int argc, char *argv[]) {
 
         log_parse_environment();
         log_set_target(LOG_TARGET_CONSOLE); /* syslog will die if not gone yet */
+        log_close_console(); /* force reopen of /dev/console */
         log_open();
 
         umask(0022);
diff --git a/src/shared/log.c b/src/shared/log.c
index 8f4995a..bd918fb 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -272,8 +272,6 @@ int log_open(void) {
         log_close_journal();
         log_close_syslog();
 
-        /* Get the real /dev/console if we are PID=1, hence reopen */
-        log_close_console();
         return log_open_console();
 }