1 /* vi: set sw=4 ts=4: */
3 * chvt.c - aeb - 940227 - Change virtual terminal
5 * busyboxed by Erik Andersen
11 #include <sys/types.h>
12 #include <sys/ioctl.h>
14 /* From <linux/vt.h> */
15 #define VT_ACTIVATE 0x5606 /* make vt active */
16 #define VT_WAITACTIVE 0x5607 /* wait for vt active */
19 int chvt_main(int argc, char **argv)
23 if ((argc != 2) || (**(argv + 1) == '-')) {
25 #ifndef BB_FEATURE_TRIVIAL_HELP
26 "\nChanges the foreground virtual terminal to /dev/ttyN\n"
30 fd = get_console_fd("/dev/console");
32 if (ioctl(fd, VT_ACTIVATE, num)) {
33 perror("VT_ACTIVATE");
36 if (ioctl(fd, VT_WAITACTIVE, num)) {
37 perror("VT_WAITACTIVE");