mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Detect termination signals (#127)
This commit is contained in:
parent
fe4aab50b1
commit
db7b82fc01
1 changed files with 9 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#ifdef TARGET_WEB
|
#ifdef TARGET_WEB
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
|
@ -260,12 +261,17 @@ void game_deinit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_exit(void) {
|
void game_exit(void) {
|
||||||
|
LOG_INFO("exiting cleanly");
|
||||||
game_deinit();
|
game_deinit();
|
||||||
#ifndef TARGET_WEB
|
#ifndef TARGET_WEB
|
||||||
exit(0);
|
exit(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inthand(UNUSED int signum) {
|
||||||
|
game_exit();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef TARGET_WEB
|
#ifdef TARGET_WEB
|
||||||
static void em_main_loop(void) {
|
static void em_main_loop(void) {
|
||||||
}
|
}
|
||||||
|
@ -431,6 +437,9 @@ void main_func(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
signal(SIGINT, inthand);
|
||||||
|
signal(SIGQUIT, inthand);
|
||||||
|
signal(SIGTERM, inthand);
|
||||||
parse_cli_opts(argc, argv);
|
parse_cli_opts(argc, argv);
|
||||||
main_func();
|
main_func();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue