summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorOlivier Brunel <jjk@jjacky.com>2013-09-20 22:18:28 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-11-13 23:22:30 -0500
commit8aa5429a4a59abbcf567938fa6ef60bb2c8ae2f1 (patch)
treefc6159aa691e095fd620b31f45e53e77621b28c7 /src/shared/util.c
parent51d0f1c9f6a378f3bf11179e5794dc2c13b49644 (diff)
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.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 838885a464..b77d010d2d 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3700,6 +3700,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;
}