3
0

deallocvt.c 797 B

12345678910111213141516171819202122232425262728293031323334353637
  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. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  9. */
  10. /* no options, no getopt */
  11. #include "busybox.h"
  12. /* From <linux/vt.h> */
  13. enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
  14. int deallocvt_main(int argc, char *argv[])
  15. {
  16. /* num = 0 deallocate all unused consoles */
  17. int num = 0;
  18. switch (argc) {
  19. case 2:
  20. num = xatoul_range(argv[1], 1, 63);
  21. /* Fallthrough */
  22. case 1:
  23. break;
  24. default:
  25. bb_show_usage();
  26. }
  27. if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
  28. bb_perror_msg_and_die("VT_DISALLOCATE");
  29. }
  30. return EXIT_SUCCESS;
  31. }