diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-18 16:49:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-18 18:21:27 +0100 |
commit | 0e6eaa2d98fffa86d29a9616485b7ade5c160638 (patch) | |
tree | 46b5ef41ae031ecb71a0b787746ca726b661a83a /src/shared/log.c | |
parent | 74f9e0f20368116fe09f9bf0e5eb0aba08e6ee42 (diff) |
log: when we log to /dev/console and got disconnected (maybe due to vhangup) reconnect
Diffstat (limited to 'src/shared/log.c')
-rw-r--r-- | src/shared/log.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/shared/log.c b/src/shared/log.c index 85ed6ecb67..b5b82f61c1 100644 --- 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"); - 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; } |