3
0

fgconsole.c 795 B

123456789101112131415161718192021222324252627282930
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Mini fgconsole implementation for busybox
  4. *
  5. * Copyright (C) 2010 by Grigory Batalov <bga@altlinux.org>
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  8. */
  9. #include "libbb.h"
  10. /* From <linux/vt.h> */
  11. struct vt_stat {
  12. unsigned short v_active; /* active vt */
  13. unsigned short v_signal; /* signal to send */
  14. unsigned short v_state; /* vt bitmask */
  15. };
  16. enum { VT_GETSTATE = 0x5603 }; /* get global vt state info */
  17. int fgconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  18. int fgconsole_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
  19. {
  20. struct vt_stat vtstat;
  21. vtstat.v_active = 0;
  22. xioctl(get_console_fd_or_die(), VT_GETSTATE, &vtstat);
  23. printf("%d\n", vtstat.v_active);
  24. return EXIT_SUCCESS;
  25. }