- if (argc == 1) {
- /* deallocate all unused consoles */
- if (ioctl(fd,VT_DISALLOCATE,0)) {
- perror("VT_DISALLOCATE");
- exit(1);
+ if (argc == 1) {
+ /* deallocate all unused consoles */
+ if (ioctl(fd, VT_DISALLOCATE, 0))
+ perror_msg_and_die("VT_DISALLOCATE");
+ } else {
+ for (i = 1; i < argc; i++) {
+ num = atoi(argv[i]);
+ if (num == 0)
+ error_msg("0: illegal VT number");
+ else if (num == 1)
+ error_msg("VT 1 cannot be deallocated");
+ else if (ioctl(fd, VT_DISALLOCATE, num))
+ perror_msg_and_die("VT_DISALLOCATE");
+ }