Updates to a number of apps to remove warnings/compile errors under libc5.
[oweals/busybox.git] / console-tools / chvt.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * chvt.c - aeb - 940227 - Change virtual terminal
4  *
5  * busyboxed by Erik Andersen
6  */
7 #include "internal.h"
8 #include <sys/types.h>
9 #include <sys/ioctl.h>
10 #include <linux/vt.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <fcntl.h>
14
15 int chvt_main(int argc, char **argv)
16 {
17         int fd, num;
18
19         if ((argc != 2) || (**(argv + 1) == '-')) {
20                 usage ("chvt N\n"
21 #ifndef BB_FEATURE_TRIVIAL_HELP
22                                 "\nChanges the foreground virtual terminal to /dev/ttyN\n"
23 #endif
24                                 );
25         }
26         fd = get_console_fd("/dev/console");
27         num = atoi(argv[1]);
28         if (ioctl(fd, VT_ACTIVATE, num)) {
29                 perror("VT_ACTIVATE");
30                 exit(FALSE);
31         }
32         if (ioctl(fd, VT_WAITACTIVE, num)) {
33                 perror("VT_WAITACTIVE");
34                 exit(FALSE);
35         }
36         return(TRUE);
37 }
38
39
40 /*
41 Local Variables:
42 c-file-style: "linux"
43 c-basic-offset: 4
44 tab-width: 4
45 End:
46 */