Support Uno4k/Ultimo4k
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-vuplus / enigma2 / enigma2 / enigma2_vuplus_sigterm.patch
diff --git a/meta-openvuplus/recipes-vuplus/enigma2/enigma2/enigma2_vuplus_sigterm.patch b/meta-openvuplus/recipes-vuplus/enigma2/enigma2/enigma2_vuplus_sigterm.patch
new file mode 100644 (file)
index 0000000..b5b72a3
--- /dev/null
@@ -0,0 +1,113 @@
+diff --git a/main/enigma.cpp b/main/enigma.cpp
+old mode 100644
+new mode 100755
+index 49c5017..6ea4a64
+--- a/main/enigma.cpp
++++ b/main/enigma.cpp
+@@ -122,6 +122,48 @@ public:
+ int exit_code;
++void quitMainloop(int exitCode)
++{
++      FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w");
++      if (f)
++      {
++              fprintf(f, "%d", 0);
++              fclose(f);
++      }
++      else
++      {
++              int fd = open("/dev/dbox/fp0", O_WRONLY);
++              if (fd >= 0)
++              {
++                      if (ioctl(fd, 10 /*FP_CLEAR_WAKEUP_TIMER*/) < 0)
++                              eDebug("FP_CLEAR_WAKEUP_TIMER failed (%m)");
++                      close(fd);
++              }
++              else
++                      eDebug("open /dev/dbox/fp0 for wakeup timer clear failed!(%m)");
++      }
++      exit_code = exitCode;
++      eApp->quit(0);
++}
++
++static void sigterm_handler(int num)
++{
++      quitMainloop(128 + num);
++}
++
++void setSigTermHandler()
++{
++      struct sigaction act;
++
++      act.sa_handler = sigterm_handler;
++      act.sa_flags = SA_RESTART;
++
++      if (sigemptyset(&act.sa_mask) == -1)
++              perror("sigemptyset");
++      if (sigaction(SIGTERM, &act, 0) == -1)
++              perror("SIGTERM");
++}
++
+ int main(int argc, char **argv)
+ {
+ #ifdef MEMLEAK_CHECK
+@@ -232,6 +274,8 @@ int main(int argc, char **argv)
+       
+       bsodCatchSignals();
++      setSigTermHandler();
++
+       setIoPrio(IOPRIO_CLASS_BE, 3);
+ //    python.execute("mytest", "__main__");
+@@ -269,47 +313,9 @@ eApplication *getApplication()
+       return eApp;
+ }
+-void quitMainloop(int exitCode)
+-{
+-      FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w");
+-      if (f)
+-      {
+-              fprintf(f, "%d", 0);
+-              fclose(f);
+-      }
+-      else
+-      {
+-              int fd = open("/dev/dbox/fp0", O_WRONLY);
+-              if (fd >= 0)
+-              {
+-                      if (ioctl(fd, 10 /*FP_CLEAR_WAKEUP_TIMER*/) < 0)
+-                              eDebug("FP_CLEAR_WAKEUP_TIMER failed (%m)");
+-                      close(fd);
+-              }
+-              else
+-                      eDebug("open /dev/dbox/fp0 for wakeup timer clear failed!(%m)");
+-      }
+-      exit_code = exitCode;
+-      eApp->quit(0);
+-}
+-
+-static void sigterm_handler(int num)
+-{
+-      quitMainloop(128 + num);
+-}
+-
+ void runMainloop()
+ {
+-      struct sigaction act;
+-
+-      act.sa_handler = sigterm_handler;
+-      act.sa_flags = SA_RESTART;
+-
+-      if (sigemptyset(&act.sa_mask) == -1)
+-              perror("sigemptyset");
+-      if (sigaction(SIGTERM, &act, 0) == -1)
+-              perror("SIGTERM");
+-
++      setSigTermHandler();
+       eApp->runLoop();
+ }