Detect termination signals (#127)
This commit is contained in:
parent
658588b05e
commit
074c915335
|
@ -1,6 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef TARGET_WEB
|
||||
#include <emscripten.h>
|
||||
|
@ -260,12 +261,17 @@ void game_deinit(void) {
|
|||
}
|
||||
|
||||
void game_exit(void) {
|
||||
LOG_INFO("exiting cleanly");
|
||||
game_deinit();
|
||||
#ifndef TARGET_WEB
|
||||
exit(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void inthand(UNUSED int signum) {
|
||||
game_exit();
|
||||
}
|
||||
|
||||
#ifdef TARGET_WEB
|
||||
static void em_main_loop(void) {
|
||||
}
|
||||
|
@ -431,6 +437,9 @@ void main_func(void) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
signal(SIGINT, inthand);
|
||||
signal(SIGQUIT, inthand);
|
||||
signal(SIGTERM, inthand);
|
||||
parse_cli_opts(argc, argv);
|
||||
main_func();
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue