Merge pull request #142 from DeadStarlin/SIGINTExitWithError

CLI idle exit with success
This commit is contained in:
PaulCombal 2022-11-30 17:56:51 +00:00 committed by GitHub
commit 9bc4d994b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,6 @@
void handle_sigint_cli(int signum)
{
std::cout << "Quitting cli idling" << std::endl;
g_steam->quit_game();
exit(EXIT_SUCCESS);
}
@ -23,7 +22,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
@ -296,7 +301,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)
{