aboutsummaryrefslogtreecommitdiff
path: root/deallocvt.c
diff options
context:
space:
mode:
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}