diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 91c26ac0..5aa75b2a 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -1,6 +1,7 @@ #include #include #include +#include #ifdef TARGET_WEB #include @@ -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;