Add pancyrillic font
[platform/upstream/kbd.git] / src / spawn_console.c
1 /*
2  * Tiny test program for the `spawn console' key
3  * (should not use signal; should not use sleep)
4  * aeb - 941025
5  *
6  * Note: this functionality will probably go away and become
7  * part of init. For the time being, be very careful when
8  * you use this - if you have this in /etc/rc.local you should
9  * start getty, not openvt, or anybody will have a root shell
10  * with a single keystroke.
11  */
12 #include <signal.h>
13 #include <errno.h>
14 #include <linux/kd.h>
15 #include <stdio.h>
16 #include <stdlib.h>     /* system */
17 #include <fcntl.h>      /* open */
18 #include <sys/ioctl.h>  /* ioctl */
19 #include <unistd.h>     /* sleep */
20
21 #include "kbd.h"
22
23 static void
24 sighup(int n __attribute__ ((unused))) {
25     if (system("openvt -s -l bash") == -1) {
26       perror("system");
27       exit(1);
28     }
29     signal(SIGHUP, sighup);
30 }
31
32 int
33 main(void) {
34     int fd;
35
36     fd = open("/dev/tty0", 0);
37     if (fd < 0 && errno == ENOENT)
38       fd = open("/dev/vc/0", 0);
39     if (fd < 0)
40       fd = 0;
41     signal(SIGHUP, sighup);
42     if (ioctl(fd, KDSIGACCEPT, (long) SIGHUP)) {
43       perror("KDSIGACCEPT");
44       exit(1);
45     }
46     while(1)
47       sleep(3600);
48 }