Skip to content

Commit 1061f58

Browse files
committed
fixed program termination
1 parent 2058070 commit 1061f58

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/ppuc.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ bool opt_pup = false;
4343
bool opt_console_display = false;
4444
const char* opt_rom = NULL;
4545
int game_state = 0;
46+
bool running = true;
4647

4748
static struct cag_option options[] = {
4849
{.identifier = 'c',
@@ -424,8 +425,16 @@ void PINMAMECALLBACK OnConsoleDataUpdated(void* p_data, int size, const void* p_
424425

425426
int PINMAMECALLBACK IsKeyPressed(PINMAME_KEYCODE keycode, const void* p_userData) { return 0; }
426427

427-
int main(int argc, char* argv[])
428+
void signal_handler(int sig) { running = false; }
429+
430+
int main(int argc, char** argv)
428431
{
432+
signal(SIGHUP, signal_handler);
433+
signal(SIGKILL, signal_handler);
434+
signal(SIGTERM, signal_handler);
435+
signal(SIGQUIT, signal_handler);
436+
signal(SIGABRT, signal_handler);
437+
429438
char identifier;
430439
cag_option_context cag_context;
431440
const char* config_file = NULL;
@@ -834,7 +843,6 @@ int main(int argc, char* argv[])
834843

835844
ppuc->StartUpdates();
836845

837-
bool running = true;
838846
while (running)
839847
{
840848
std::this_thread::sleep_for(std::chrono::microseconds(sleep_us));
@@ -908,6 +916,9 @@ int main(int argc, char* argv[])
908916
}
909917
}
910918
}
919+
920+
ppuc->StopUpdates();
921+
PinmameStop();
911922
}
912923

913924
if (!opt_no_serial)

0 commit comments

Comments
 (0)