1 /* vi: set sw=4 ts=4: */
3 * disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
10 #include <sys/types.h>
11 #include <sys/ioctl.h>
13 /* From <linux/vt.h> */
14 #define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
16 const char deallocvt_usage[] =
18 #ifndef BB_FEATURE_TRIVIAL_HELP
19 "\nDeallocate unused virtual terminal /dev/ttyN\n"
23 int deallocvt_main(int argc, char *argv[])
27 if ((argc != 2) || (**(argv + 1) == '-'))
28 usage(deallocvt_usage);
30 fd = get_console_fd("/dev/console");
33 /* deallocate all unused consoles */
34 if (ioctl(fd, VT_DISALLOCATE, 0)) {
35 perror("VT_DISALLOCATE");
39 for (i = 1; i < argc; i++) {
42 errorMsg("0: illegal VT number\n");
44 errorMsg("VT 1 cannot be deallocated\n");
45 else if (ioctl(fd, VT_DISALLOCATE, num)) {
46 perror("VT_DISALLOCATE");
47 errorMsg("could not deallocate console %d\n", num);