aboutsummaryrefslogtreecommitdiff
path: root/deallocvt.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-25 23:32:44 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-25 23:32:44 +0000
commit3c2381e1dc71b30c5511f8142ea271328e15c2dd (patch)
treed761a790ee864a0a566d29c9d56173763fa04888 /deallocvt.c
parentfbf5a726a6bc6f126c04c7949fe5820b37583530 (diff)
downloadbusybox-w32-3c2381e1dc71b30c5511f8142ea271328e15c2dd.tar.gz
busybox-w32-3c2381e1dc71b30c5511f8142ea271328e15c2dd.tar.bz2
busybox-w32-3c2381e1dc71b30c5511f8142ea271328e15c2dd.zip
Stuf
git-svn-id: svn://busybox.net/trunk/busybox@59 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'deallocvt.c')
-rw-r--r--deallocvt.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/deallocvt.c b/deallocvt.c
new file mode 100644
index 000000000..a8feeb53c
--- /dev/null
+++ b/deallocvt.c
@@ -0,0 +1,47 @@
1/*
2 * disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
3 * Renamed deallocvt.
4 */
5#include <stdlib.h>
6#include <fcntl.h>
7#include <sys/types.h>
8#include <sys/ioctl.h>
9#include <linux/vt.h>
10#include <stdio.h>
11
12extern int getfd(void);
13char *progname;
14
15int
16deallocvt_main(int argc, char *argv[]) {
17 int fd, num, i;
18
19 if (argc < 1) /* unlikely */
20 exit(1);
21 progname = argv[0];
22
23 fd = get_console_fd("/dev/console");
24
25 if (argc == 1) {
26 /* deallocate all unused consoles */
27 if (ioctl(fd,VT_DISALLOCATE,0)) {
28 perror("VT_DISALLOCATE");
29 exit(1);
30 }
31 } else
32 for (i = 1; i < argc; i++) {
33 num = atoi(argv[i]);
34 if (num == 0)
35 fprintf(stderr, "%s: 0: illegal VT number\n", progname);
36 else if (num == 1)
37 fprintf(stderr, "%s: VT 1 cannot be deallocated\n", progname);
38 else
39 if (ioctl(fd,VT_DISALLOCATE,num)) {
40 perror("VT_DISALLOCATE");
41 fprintf(stderr, "%s: could not deallocate console %d\n",
42 progname, num);
43 exit(1);
44 }
45 }
46 exit(0);
47}