]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: also protect from empty /sys/class/tty/tty0/active 40630/head
authorMike Yuan <me@yhndnzj.com>
Tue, 10 Feb 2026 21:21:25 +0000 (22:21 +0100)
committerMike Yuan <me@yhndnzj.com>
Tue, 10 Feb 2026 21:21:53 +0000 (22:21 +0100)
src/basic/terminal-util.c

index 91ef5d7c0777730bc119190538325dfa6e325729..1013e38d0dba00a80928ef49b64fcd66bed2253d 100644 (file)
@@ -1151,6 +1151,8 @@ int resolve_dev_console(char **ret) {
                 r = read_one_line_file("/sys/class/tty/tty0/active", &active);
                 if (r < 0)
                         return r;
+                if (r == 0)
+                        return -ENXIO;
 
                 tty = active;
         }
@@ -1194,6 +1196,10 @@ int get_kernel_consoles(char ***ret) {
                         r = read_one_line_file("/sys/class/tty/tty0/active", &tty);
                         if (r < 0)
                                 return r;
+                        if (r == 0) {
+                                log_debug("No VT active, skipping /dev/tty0.");
+                                continue;
+                        }
                 }
 
                 path = path_join("/dev", tty);