chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
74f9e0f
)
log: when we log to /dev/console and got disconnected (maybe due to vhangup) reconnect
author
Lennart Poettering
<lennart@poettering.net>
Wed, 18 Dec 2013 15:49:15 +0000
(16:49 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Wed, 18 Dec 2013 17:21:27 +0000
(18:21 +0100)
src/shared/log.c
patch
|
blob
|
history
diff --git
a/src/shared/log.c
b/src/shared/log.c
index 85ed6ecb67fef53f80a307c51ff7f845fa8ebdf9..b5b82f61c18774feda281b201e4e6cef2944be7f 100644
(file)
--- a/
src/shared/log.c
+++ b/
src/shared/log.c
@@
-335,8
+335,25
@@
static int write_to_console(
IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_OFF);
IOVEC_SET_STRING(iovec[n++], "\n");
IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_OFF);
IOVEC_SET_STRING(iovec[n++], "\n");
- if (writev(console_fd, iovec, n) < 0)
- return -errno;
+ if (writev(console_fd, iovec, n) < 0) {
+
+ if (errno == EIO && getpid() == 1) {
+
+ /* If somebody tried to kick us from our
+ * console tty (via vhangup() or suchlike),
+ * try to reconnect */
+
+ log_close_console();
+ log_open_console();
+
+ if (console_fd < 0)
+ return 0;
+
+ if (writev(console_fd, iovec, n) < 0)
+ return -errno;
+ } else
+ return -errno;
+ }
return 1;
}
return 1;
}