summaryrefslogtreecommitdiff
path: root/src/basic/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/log.c')
-rw-r--r--src/basic/log.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index 965781d2c..cb4689cef 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -85,35 +85,34 @@ static bool prohibit_ipc = false;
* use here. */
static char *log_abort_msg = NULL;
-void log_close_console(void) {
+static void log_close_console(void) {
if (console_fd < 0)
return;
- if (getpid_cached() == 1) {
- if (console_fd >= 3)
- safe_close(console_fd);
+ if (console_fd >= 3)
+ safe_close(console_fd);
- console_fd = -1;
- }
+ console_fd = -1;
}
static int log_open_console(void) {
- if (console_fd >= 0)
+ if (!always_reopen_console) {
+ console_fd = STDERR_FILENO;
return 0;
+ }
- if (always_reopen_console) {
+ if (console_fd < 3) {
console_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
if (console_fd < 0)
return console_fd;
- } else
- console_fd = STDERR_FILENO;
+ }
return 0;
}
-void log_close_kmsg(void) {
+static void log_close_kmsg(void) {
kmsg_fd = safe_close(kmsg_fd);
}
@@ -129,7 +128,7 @@ static int log_open_kmsg(void) {
return 0;
}
-void log_close_syslog(void) {
+static void log_close_syslog(void) {
syslog_fd = safe_close(syslog_fd);
}
@@ -201,7 +200,7 @@ fail:
return r;
}
-void log_close_journal(void) {
+static void log_close_journal(void) {
#if 0 /// elogind does not support journald
journal_fd = safe_close(journal_fd);
#endif // 0
@@ -247,7 +246,8 @@ int log_open(void) {
/* If we don't use the console we close it here, to not get
* killed by SAK. If we don't use syslog we close it here so
* that we are not confused by somebody deleting the socket in
- * the fs. If we don't use /dev/kmsg we still keep it open,
+ * the fs, and to make sure we don't use it if prohibit_ipc is
+ * set. If we don't use /dev/kmsg we still keep it open,
* because there is no reason to close it. */
if (log_target == LOG_TARGET_NULL) {