summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vt_reset.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/vt_reset.c b/vt_reset.c
new file mode 100644
index 0000000..139ab0b
--- /dev/null
+++ b/vt_reset.c
@@ -0,0 +1,36 @@
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/vt.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+main (int argc, char *argv[])
+{
+ int fd;
+ int i;
+ char buf[128];
+ struct vt_mode vm;
+
+ for (i = 1; i < 31; ++i) {
+ sprintf (buf, "/dev/tty%d", i);
+ fd = open (buf, O_RDWR | O_NOCTTY);
+
+ memset (&vm, 0, sizeof (vm));
+ vm.mode = VT_PROCESS;
+ ioctl (fd, VT_SETMODE, &vm);
+ ioctl (fd, VT_RELDISP, 0);
+ ioctl (fd, VT_RELDISP, 1);
+ ioctl (fd, VT_RELDISP, VT_ACKACQ);
+
+ memset (&vm, 0, sizeof (vm));
+ vm.mode = VT_AUTO;
+ ioctl (fd, VT_SETMODE, &vm);
+
+ ioctl (fd, VT_UNLOCKSWITCH, 0);
+
+ close (fd);
+ }
+ exit (0);
+}