diff options
| author | Andreas Oberritter <obi@opendreambox.org> | 2010-11-04 21:08:56 +0100 |
|---|---|---|
| committer | Andreas Oberritter <obi@opendreambox.org> | 2010-11-16 17:15:38 +0100 |
| commit | 5e8a1b1a1457bd345c3d07467f0a81299d991539 (patch) | |
| tree | 58a402794783cc9e405504ebbe3ff8ddf4e85e7a /main/enigma.cpp | |
| parent | f291fd2f5dac6a5ecc919234a1fd4bc3b95b40ec (diff) | |
| download | enigma2-5e8a1b1a1457bd345c3d07467f0a81299d991539.tar.gz enigma2-5e8a1b1a1457bd345c3d07467f0a81299d991539.zip | |
shutdown enigma on SIGTERM
Diffstat (limited to 'main/enigma.cpp')
| -rw-r--r-- | main/enigma.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/main/enigma.cpp b/main/enigma.cpp index 6bc35714..1cdd867b 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -268,11 +268,6 @@ eApplication *getApplication() return eApp; } -void runMainloop() -{ - eApp->runLoop(); -} - void quitMainloop(int exitCode) { FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "w"); @@ -297,6 +292,26 @@ void quitMainloop(int 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"); + + eApp->runLoop(); +} + const char *getEnigmaVersionString() { std::string date = enigma2_date; |
