diff options
Diffstat (limited to 'deallocvt.c')
-rw-r--r-- | deallocvt.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/deallocvt.c b/deallocvt.c index 1e13ff69c..141062edc 100644 --- a/deallocvt.c +++ b/deallocvt.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * disalloc.c - aeb - 940501 - Disallocate virtual terminal(s) | 3 | * disalloc.c - aeb - 940501 - Disallocate virtual terminal(s) |
3 | * Renamed deallocvt. | 4 | * Renamed deallocvt. |
@@ -13,38 +14,39 @@ | |||
13 | extern int getfd(void); | 14 | extern int getfd(void); |
14 | char *progname; | 15 | char *progname; |
15 | 16 | ||
16 | int | 17 | int deallocvt_main(int argc, char *argv[]) |
17 | deallocvt_main(int argc, char *argv[]) { | 18 | { |
18 | int fd, num, i; | 19 | int fd, num, i; |
19 | 20 | ||
20 | if ( ( argc != 2) || (**(argv+1) == '-' ) ) { | 21 | if ((argc != 2) || (**(argv + 1) == '-')) { |
21 | usage ("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n"); | 22 | usage |
22 | } | 23 | ("deallocvt N\n\nDeallocate unused virtual terminal /dev/ttyN\n"); |
24 | } | ||
23 | 25 | ||
24 | progname = argv[0]; | 26 | progname = argv[0]; |
25 | 27 | ||
26 | fd = get_console_fd("/dev/console"); | 28 | fd = get_console_fd("/dev/console"); |
27 | 29 | ||
28 | if (argc == 1) { | 30 | if (argc == 1) { |
29 | /* deallocate all unused consoles */ | 31 | /* deallocate all unused consoles */ |
30 | if (ioctl(fd,VT_DISALLOCATE,0)) { | 32 | if (ioctl(fd, VT_DISALLOCATE, 0)) { |
31 | perror("VT_DISALLOCATE"); | 33 | perror("VT_DISALLOCATE"); |
32 | exit(1); | 34 | exit(1); |
33 | } | 35 | } |
34 | } else | 36 | } else |
35 | for (i = 1; i < argc; i++) { | 37 | for (i = 1; i < argc; i++) { |
36 | num = atoi(argv[i]); | 38 | num = atoi(argv[i]); |
37 | if (num == 0) | 39 | if (num == 0) |
38 | fprintf(stderr, "%s: 0: illegal VT number\n", progname); | 40 | fprintf(stderr, "%s: 0: illegal VT number\n", progname); |
39 | else if (num == 1) | 41 | else if (num == 1) |
40 | fprintf(stderr, "%s: VT 1 cannot be deallocated\n", progname); | 42 | fprintf(stderr, "%s: VT 1 cannot be deallocated\n", |
41 | else | 43 | progname); |
42 | if (ioctl(fd,VT_DISALLOCATE,num)) { | 44 | else if (ioctl(fd, VT_DISALLOCATE, num)) { |
43 | perror("VT_DISALLOCATE"); | 45 | perror("VT_DISALLOCATE"); |
44 | fprintf(stderr, "%s: could not deallocate console %d\n", | 46 | fprintf(stderr, "%s: could not deallocate console %d\n", |
45 | progname, num); | 47 | progname, num); |
46 | exit(1); | 48 | exit(1); |
47 | } | 49 | } |
48 | } | 50 | } |
49 | exit(0); | 51 | exit(0); |
50 | } | 52 | } |