2 * Tiny test program for the `spawn console' key
3 * (should not use signal; should not use sleep)
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.
16 #include <stdlib.h> /* system */
17 #include <fcntl.h> /* open */
18 #include <sys/ioctl.h> /* ioctl */
19 #include <unistd.h> /* sleep */
24 sighup(int n __attribute__ ((unused))) {
25 if (system("openvt -s -l bash") == -1) {
29 signal(SIGHUP, sighup);
36 fd = open("/dev/tty0", 0);
37 if (fd < 0 && errno == ENOENT)
38 fd = open("/dev/vc/0", 0);
41 signal(SIGHUP, sighup);
42 if (ioctl(fd, KDSIGACCEPT, (long) SIGHUP)) {
43 perror("KDSIGACCEPT");