Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * chvt.c - aeb - 940227 - Change virtual terminal |
| 3 | * |
| 4 | * busyboxed by Erik Andersen |
| 5 | */ |
| 6 | #include "internal.h" |
| 7 | #include <sys/types.h> |
| 8 | #include <sys/ioctl.h> |
| 9 | #include <linux/vt.h> |
| 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <fcntl.h> |
| 13 | |
| 14 | extern int getfd(void); |
| 15 | |
| 16 | int |
| 17 | chvt_main(int argc, char** argv) |
| 18 | { |
| 19 | int fd, num; |
| 20 | |
| 21 | if ( ( argc != 2) || (**(argv+1) == '-' ) ) { |
Eric Andersen | d73dc5b | 1999-11-10 23:13:02 +0000 | [diff] [blame] | 22 | usage ("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n"); |
Eric Andersen | 0460ff2 | 1999-10-25 23:32:44 +0000 | [diff] [blame] | 23 | } |
| 24 | fd = get_console_fd("/dev/console"); |
| 25 | num = atoi(argv[1]); |
| 26 | if (ioctl(fd,VT_ACTIVATE,num)) { |
| 27 | perror("VT_ACTIVATE"); |
| 28 | exit(FALSE); |
| 29 | } |
| 30 | if (ioctl(fd,VT_WAITACTIVE,num)) { |
| 31 | perror("VT_WAITACTIVE"); |
| 32 | exit(FALSE); |
| 33 | } |
| 34 | exit( TRUE); |
| 35 | } |
| 36 | |