summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@no.no.james.local>2015-12-28 11:29:28 +0000
committerroot <root@no.no.james.local>2015-12-28 11:29:28 +0000
commit72322a8dc53c0c6c64b9a706c75b327eae6e0160 (patch)
tree4b24128c39a32f9a79fdc5b6fd7fa2458f31b856
parent5e4cc437931fb429f9187523de1cfac93e2cb80e (diff)
downloadkobo-tools-72322a8dc53c0c6c64b9a706c75b327eae6e0160.tar.gz
kobo-tools-72322a8dc53c0c6c64b9a706c75b327eae6e0160.tar.bz2
kobo-tools-72322a8dc53c0c6c64b9a706c75b327eae6e0160.zip
add vtreset
-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);
+}