summaryrefslogtreecommitdiffhomepage
path: root/console-tools
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-04-16 21:48:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-16 21:48:32 +0200
commit816d8d7a668b541cee99469edb90e4917ea11c3e (patch)
tree84d10ca9173bf499a23de61e577a94639fdaeec2 /console-tools
parentfa87abe807530daeb46f6730d4231489a4e2782b (diff)
setlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'console-tools')
-rw-r--r--console-tools/setlogcons.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/console-tools/setlogcons.c b/console-tools/setlogcons.c
index 6778a4d2b..0fad6600a 100644
--- a/console-tools/setlogcons.c
+++ b/console-tools/setlogcons.c
@@ -41,6 +41,7 @@
int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setlogcons_main(int argc UNUSED_PARAM, char **argv)
{
+ char *devname;
struct {
char fn;
char subarg;
@@ -52,7 +53,14 @@ int setlogcons_main(int argc UNUSED_PARAM, char **argv)
if (argv[1])
arg.subarg = xatou_range(argv[1], 0, 63);
- xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
+ /* Can just call it on "/dev/tty1" always, but...
+ * in my testing, inactive (never opened) VTs are not
+ * redirected to, despite ioctl not failing.
+ *
+ * By using "/dev/ttyN", ensure it is activated.
+ */
+ devname = xasprintf("/dev/tty%u", arg.subarg);
+ xioctl(xopen(devname, O_RDONLY), TIOCLINUX, &arg);
return EXIT_SUCCESS;
}