Blame SOURCES/0144-log-when-we-log-to-dev-console-and-got-disconnected-.patch
|
|
9fc0f6 |
From 87823e84ec7b0e6939596063c540219a681bbbb9 Mon Sep 17 00:00:00 2001
|
|
|
9fc0f6 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
9fc0f6 |
Date: Wed, 18 Dec 2013 16:49:15 +0100
|
|
|
9fc0f6 |
Subject: [PATCH] log: when we log to /dev/console and got disconnected (maybe
|
|
|
9fc0f6 |
due to vhangup) reconnect
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
---
|
|
|
9fc0f6 |
src/shared/log.c | 21 +++++++++++++++++++--
|
|
|
9fc0f6 |
1 file changed, 19 insertions(+), 2 deletions(-)
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
diff --git a/src/shared/log.c b/src/shared/log.c
|
|
|
9fc0f6 |
index 8f4995a..605d069 100644
|
|
|
9fc0f6 |
--- a/src/shared/log.c
|
|
|
9fc0f6 |
+++ b/src/shared/log.c
|
|
|
9fc0f6 |
@@ -337,8 +337,25 @@ static int write_to_console(
|
|
|
9fc0f6 |
IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_OFF);
|
|
|
9fc0f6 |
IOVEC_SET_STRING(iovec[n++], "\n");
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- if (writev(console_fd, iovec, n) < 0)
|
|
|
9fc0f6 |
- return -errno;
|
|
|
9fc0f6 |
+ if (writev(console_fd, iovec, n) < 0) {
|
|
|
9fc0f6 |
+
|
|
|
9fc0f6 |
+ if (errno == EIO && getpid() == 1) {
|
|
|
9fc0f6 |
+
|
|
|
9fc0f6 |
+ /* If somebody tried to kick us from our
|
|
|
9fc0f6 |
+ * console tty (via vhangup() or suchlike),
|
|
|
9fc0f6 |
+ * try to reconnect */
|
|
|
9fc0f6 |
+
|
|
|
9fc0f6 |
+ log_close_console();
|
|
|
9fc0f6 |
+ log_open_console();
|
|
|
9fc0f6 |
+
|
|
|
9fc0f6 |
+ if (console_fd < 0)
|
|
|
9fc0f6 |
+ return 0;
|
|
|
9fc0f6 |
+
|
|
|
9fc0f6 |
+ if (writev(console_fd, iovec, n) < 0)
|
|
|
9fc0f6 |
+ return -errno;
|
|
|
9fc0f6 |
+ } else
|
|
|
9fc0f6 |
+ return -errno;
|
|
|
9fc0f6 |
+ }
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
return 1;
|
|
|
9fc0f6 |
}
|