mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-09-04 04:31:27 +00:00
Resolve /dev/console to the active tty instead of just "tty0"
When resolving /dev/console one would often get "tty0" meaning the active VT. Resolving to the actual tty (e.g. "tty1") will notably help on boot when determining whether or not PID1 can output to the console.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
1e74ecdeda
commit
5c294f2b21
@@ -3600,6 +3600,16 @@ char *resolve_dev_console(char **active) {
|
||||
else
|
||||
tty = *active;
|
||||
|
||||
if (streq(tty, "tty0")) {
|
||||
char *tmp;
|
||||
|
||||
/* Get the active VC (e.g. tty1) */
|
||||
if (read_one_line_file("/sys/class/tty/tty0/active", &tmp) >= 0) {
|
||||
free(*active);
|
||||
tty = *active = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return tty;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user