From d5a1c99b25e549f44ca6f5f8006b90ee56b809f9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Aug 2019 17:32:17 +0200 Subject: [PATCH] log: don't invalidate open console fd if we can't open a new one --- src/basic/log.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/basic/log.c b/src/basic/log.c index 6095f0fdec..8bcc18bc80 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -87,11 +87,13 @@ static int log_open_console(void) { } if (console_fd < 3) { - console_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC); - if (console_fd < 0) - return console_fd; + int fd; - console_fd = fd_move_above_stdio(console_fd); + fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC); + if (fd < 0) + return fd; + + console_fd = fd_move_above_stdio(fd); } return 0;