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 */
17 int deallocvt_main(int argc, char *argv[])
21 if ((argc != 2) || (**(argv + 1) == '-')) {
24 #ifndef BB_FEATURE_TRIVIAL_HELP
25 "\nDeallocate unused virtual terminal /dev/ttyN\n"
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 fprintf(stderr, "%s: 0: illegal VT number\n", applet_name);
44 fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
46 else if (ioctl(fd, VT_DISALLOCATE, num)) {
47 perror("VT_DISALLOCATE");
48 fprintf(stderr, "%s: could not deallocate console %d\n",