aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorpk33 <pk33@email.com>2024-11-03 12:07:55 +0100
committerpk33 <pk33@email.com>2024-11-03 12:07:55 +0100
commit844a19f9bfe01286ca9974aff0e6d38693e05877 (patch)
treebeca8efb8300fe3b6c78e9da26560cf674b57595 /src/main.c
parent23ab6c4e6483159b77af8b4edf95113887a300d7 (diff)
downloadengine33-844a19f9bfe01286ca9974aff0e6d38693e05877.tar.gz
cleanup code & term handlers
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 150f16c..1b9b2d3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,6 +2,9 @@
#include "clock.h"
#include "logger.h"
#include "system.h"
+#include "signal.h"
+
+static void _term_sighandler( int sig );
int main(int argc, char *argv[])
@@ -9,6 +12,10 @@ int main(int argc, char *argv[])
Size fps, FPS;
long timeOld, time;
+ if( e33_set_signal( SIGHUP, _term_sighandler ) == -1 ) { logw( "SIGHUP not handled"); }
+ if( e33_set_signal( SIGINT, _term_sighandler ) == -1 ) { logw( "SIGINT not handled"); }
+ if( e33_set_signal( SIGTERM, _term_sighandler ) == -1 ) { logw( "SIGTERM not handled"); }
+
timeOld = clock_get_us();
time = 0;
fps = 0;
@@ -52,3 +59,12 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
+
+
+static void _term_sighandler( int sig )
+{
+ display_term();
+ logger_term();
+ exit(0);
+}
+