From a01cf5b2e082a015a5bd50db208a7a997923fcfd Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Fri, 6 Feb 2026 02:07:05 +0100 Subject: [PATCH] terminal-util: handle the case where no system console is active /dev/console might have no backing driver, in which case /sys/class/tty/console/active is empty. Unlike get_kernel_consoles() resolve_dev_console() currently proceeds with empty devnode, resulting in setup_input() -> acquire_terminal() emitting -EISDIR as we're trying to open /dev/. Let's catch this and report -ENXIO. --- src/basic/terminal-util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 01c2bd37505..91ef5d7c077 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1116,7 +1116,7 @@ int resolve_dev_console(char **ret) { * is a sign for container setups). */ _cleanup_free_ char *chased = NULL; - r = chase("/dev/console", /* root= */ NULL, /* flags= */ 0, &chased, /* ret_fd= */ NULL); + r = chase("/dev/console", /* root= */ NULL, /* flags= */ 0, &chased, /* ret_fd= */ NULL); if (r < 0) return r; if (!path_equal(chased, "/dev/console")) { @@ -1134,6 +1134,8 @@ int resolve_dev_console(char **ret) { r = read_one_line_file("/sys/class/tty/console/active", &active); if (r < 0) return r; + if (r == 0) + return -ENXIO; /* If multiple log outputs are configured the last one is what /dev/console points to */ const char *tty = strrchr(active, ' '); -- 2.47.3