Support Uno4k/Ultimo4k
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-vuplus / enigma2 / enigma2 / enigma2_vuplus_sigterm.patch
1 diff --git a/main/enigma.cpp b/main/enigma.cpp
2 old mode 100644
3 new mode 100755
4 index 49c5017..6ea4a64
5 --- a/main/enigma.cpp
6 +++ b/main/enigma.cpp
7 @@ -122,6 +122,48 @@ public:
8  
9  int exit_code;
10  
11 +void quitMainloop(int exitCode)
12 +{
13 +       FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w");
14 +       if (f)
15 +       {
16 +               fprintf(f, "%d", 0);
17 +               fclose(f);
18 +       }
19 +       else
20 +       {
21 +               int fd = open("/dev/dbox/fp0", O_WRONLY);
22 +               if (fd >= 0)
23 +               {
24 +                       if (ioctl(fd, 10 /*FP_CLEAR_WAKEUP_TIMER*/) < 0)
25 +                               eDebug("FP_CLEAR_WAKEUP_TIMER failed (%m)");
26 +                       close(fd);
27 +               }
28 +               else
29 +                       eDebug("open /dev/dbox/fp0 for wakeup timer clear failed!(%m)");
30 +       }
31 +       exit_code = exitCode;
32 +       eApp->quit(0);
33 +}
34 +
35 +static void sigterm_handler(int num)
36 +{
37 +       quitMainloop(128 + num);
38 +}
39 +
40 +void setSigTermHandler()
41 +{
42 +       struct sigaction act;
43 +
44 +       act.sa_handler = sigterm_handler;
45 +       act.sa_flags = SA_RESTART;
46 +
47 +       if (sigemptyset(&act.sa_mask) == -1)
48 +               perror("sigemptyset");
49 +       if (sigaction(SIGTERM, &act, 0) == -1)
50 +               perror("SIGTERM");
51 +}
52 +
53  int main(int argc, char **argv)
54  {
55  #ifdef MEMLEAK_CHECK
56 @@ -232,6 +274,8 @@ int main(int argc, char **argv)
57         
58         bsodCatchSignals();
59  
60 +       setSigTermHandler();
61 +
62         setIoPrio(IOPRIO_CLASS_BE, 3);
63  
64  //     python.execute("mytest", "__main__");
65 @@ -269,47 +313,9 @@ eApplication *getApplication()
66         return eApp;
67  }
68  
69 -void quitMainloop(int exitCode)
70 -{
71 -       FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w");
72 -       if (f)
73 -       {
74 -               fprintf(f, "%d", 0);
75 -               fclose(f);
76 -       }
77 -       else
78 -       {
79 -               int fd = open("/dev/dbox/fp0", O_WRONLY);
80 -               if (fd >= 0)
81 -               {
82 -                       if (ioctl(fd, 10 /*FP_CLEAR_WAKEUP_TIMER*/) < 0)
83 -                               eDebug("FP_CLEAR_WAKEUP_TIMER failed (%m)");
84 -                       close(fd);
85 -               }
86 -               else
87 -                       eDebug("open /dev/dbox/fp0 for wakeup timer clear failed!(%m)");
88 -       }
89 -       exit_code = exitCode;
90 -       eApp->quit(0);
91 -}
92 -
93 -static void sigterm_handler(int num)
94 -{
95 -       quitMainloop(128 + num);
96 -}
97 -
98  void runMainloop()
99  {
100 -       struct sigaction act;
101 -
102 -       act.sa_handler = sigterm_handler;
103 -       act.sa_flags = SA_RESTART;
104 -
105 -       if (sigemptyset(&act.sa_mask) == -1)
106 -               perror("sigemptyset");
107 -       if (sigaction(SIGTERM, &act, 0) == -1)
108 -               perror("SIGTERM");
109 -
110 +       setSigTermHandler();
111         eApp->runLoop();
112  }
113