source: MondoRescue/branches/2.2.2/mindi-busybox/console-tools/deallocvt.c@ 1247

Last change on this file since 1247 was 821, checked in by Bruno Cornec, 18 years ago

Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)

File size: 1.6 KB
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * Disallocate virtual terminal(s)
4 *
5 * Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
6 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
7 *
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.
12 *
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.
17 *
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
21 */
22
23/* no options, no getopt */
24
25#include <stdlib.h>
26#include <stdio.h>
27#include <fcntl.h>
28#include <sys/types.h>
29#include <sys/ioctl.h>
30#include "busybox.h"
31
32/* From <linux/vt.h> */
33enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
34
35int deallocvt_main(int argc, char *argv[])
36{
37 /* num = 0 deallocate all unused consoles */
38 int num = 0;
39
40 switch (argc) {
41 case 2:
42 if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) {
43 bb_error_msg_and_die("0: illegal VT number");
44 }
45 /* Fallthrough */
46 case 1:
47 break;
48 default:
49 bb_show_usage();
50 }
51
52 if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
53 bb_perror_msg_and_die("VT_DISALLOCATE");
54 }
55 return EXIT_SUCCESS;
56}
Note: See TracBrowser for help on using the repository browser.