]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log: don't invalidate open console fd if we can't open a new one
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Aug 2019 15:32:17 +0000 (17:32 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 Aug 2019 15:32:17 +0000 (17:32 +0200)
src/basic/log.c

index 6095f0fdec9a8a155cb70eac9a29552bc102ecb4..8bcc18bc809abd833e25a54cbab89052a39a30f3 100644 (file)
@@ -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;