mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-10-04 07:48:36 +00:00
log: when we log to /dev/console and got disconnected (maybe due to vhangup) reconnect
This commit is contained in:
+19
-2
@@ -335,8 +335,25 @@ static int write_to_console(
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user