From 10c44b46659e124db3a4ab08b88d9dc7f8de7c46 Mon Sep 17 00:00:00 2001 From: DeadStarlin Date: Wed, 30 Nov 2022 14:35:35 +0100 Subject: [PATCH] CLI idle exit with success --- src/cli/cli_funcs.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cli/cli_funcs.cpp b/src/cli/cli_funcs.cpp index 0872588..c0cb495 100644 --- a/src/cli/cli_funcs.cpp +++ b/src/cli/cli_funcs.cpp @@ -13,7 +13,6 @@ void handle_sigint_cli(int signum) { std::cout << "Quitting cli idling" << std::endl; - g_steam->quit_game(); exit(EXIT_SUCCESS); } @@ -21,7 +20,13 @@ void idle_app(AppId_t appid) { std::cout << "Idling from command line " << appid << std::endl; g_steam->launch_app(appid); - signal(SIGINT, handle_sigint_cli); + struct sigaction sigIntHandler; + + sigIntHandler.sa_handler = handle_sigint_cli; + sigemptyset(&sigIntHandler.sa_mask); + sigIntHandler.sa_flags = 0; + + sigaction(SIGINT, &sigIntHandler, NULL); // Wait for ctrl+c, so we can kill both processes, otherwise // GUI process will exit while game process still goes on @@ -221,7 +226,13 @@ bool go_cli_mode(int argc, char* argv[], AppId_t *return_app_id) { if (result.count("timed") > 0) { // Hook this up since we'll probably be in this function for a while // Really we could hook this up whenever we launch the app... - signal(SIGINT, handle_sigint_cli); + struct sigaction sigIntHandler; + + sigIntHandler.sa_handler = handle_sigint_cli; + sigemptyset(&sigIntHandler.sa_mask); + sigIntHandler.sa_flags = 0; + + sigaction(SIGINT, &sigIntHandler, NULL); if (app == 0) {