From 95300a5e6be762c1c4fd4626f033d79779d3f974 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 6 Oct 2012 22:05:39 +0200 Subject: [PATCH] Add some VT switching and locking --- defines.h | 1 + main.cc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/defines.h b/defines.h index 5358246..1bbdec6 100644 --- a/defines.h +++ b/defines.h @@ -112,6 +112,7 @@ long long getTimeMS(); #define DEFAULT_TCP_WINDOWSIZENR 6 /*=2048*/ #define TV_NORM_SWITCHABLE + #define HANDLE_VT_SWITCHING #define VOMP_LINUX_CLOCK CLOCK_MONOTONIC diff --git a/main.cc b/main.cc index 237b233..ae156b0 100644 --- a/main.cc +++ b/main.cc @@ -28,6 +28,12 @@ #endif #include "defines.h" + +#ifdef HANDLE_VT_SWITCHING +#include +#include +#include +#endif #include "log.h" #include "timers.h" #include "vdr.h" @@ -104,6 +110,11 @@ Audio* audio; Wol* wol; Sleeptimer* sleeptimer; +#ifdef HANDLE_VT_SWITCHING +int fdtty; +struct vt_mode old_vtmode; +#endif + // Linux MVP main function and sighandler #ifndef WIN32 int main(int argc, char** argv) @@ -243,6 +254,21 @@ int main(int argc, char** argv) logger->log("Core", Log::INFO, "Signal handlers set up successfully"); +#ifdef HANDLE_VT_SWITCHING + if ((fdtty = open("/dev/tty", O_WRONLY),0) == -1) { + logger->log("Core", Log::EMERG, "Could not open /dev/tty. Please change permissions"); + } else { + int free_vt; + if (ioctl(fdtty,VT_OPENQRY,&free_vt)==-1 || free_vt==-1){ + logger->log("Core", Log::EMERG, "Could not retrieve free virtual console, please change permissions"); + } else { + ioctl(fdtty,VT_ACTIVATE,free_vt); + ioctl(fdtty,VT_WAITACTIVE,free_vt); + ioctl(fdtty, VT_LOCKSWITCH, 1); + } + } + +#endif // Init modules ---------------------------------------------------------------------------------------------------- int success; @@ -515,6 +541,10 @@ void shutdown(int code) delete sleeptimer; logger->log("Core", Log::NOTICE, "Sleeptimer module shut down"); } +#ifdef HANDLE_VT_SWITCHING + ioctl(fdtty, VT_UNLOCKSWITCH, 1); + close(fdtty); +#endif if (logger) { -- 2.39.5