CLI idle exit with success

This commit is contained in:
DeadStarlin 2022-11-30 14:35:35 +01:00
parent 04f02fe69d
commit 10c44b4665

View File

@ -13,7 +13,6 @@
void handle_sigint_cli(int signum) void handle_sigint_cli(int signum)
{ {
std::cout << "Quitting cli idling" << std::endl; std::cout << "Quitting cli idling" << std::endl;
g_steam->quit_game();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -21,7 +20,13 @@ void idle_app(AppId_t appid)
{ {
std::cout << "Idling from command line " << appid << std::endl; std::cout << "Idling from command line " << appid << std::endl;
g_steam->launch_app(appid); 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 // Wait for ctrl+c, so we can kill both processes, otherwise
// GUI process will exit while game process still goes on // 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) { if (result.count("timed") > 0) {
// Hook this up since we'll probably be in this function for a while // 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... // 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) if (app == 0)
{ {