1 /* vi: set sw=4 ts=4: */
3 * Disallocate virtual terminal(s)
5 * Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
6 * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /* no options, no getopt */
28 #include <sys/types.h>
29 #include <sys/ioctl.h>
32 /* From <linux/vt.h> */
33 static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
35 int deallocvt_main(int argc, char *argv[])
43 fd = get_console_fd();
45 /* num=0 deallocate all unused consoles */
50 num = bb_xgetlarg(argv[1], 10, 0, INT_MAX);
53 bb_error_msg("0: illegal VT number");
56 bb_error_msg("VT 1 cannot be deallocated");
60 if (ioctl(fd, VT_DISALLOCATE, num)) {
61 bb_perror_msg_and_die("VT_DISALLOCATE");