Xbox Cloud Gaming app for PS5 Homebrew
C
psbox: Ctrl+C and SIGTERM close it in order even when SIGINT came ignored
Rafael Abud Ferreira7d83ee1b084a
diff --git a/src/app/shell_desktop.cpp b/src/app/shell_desktop.cppindex 148264c..22c476c 100644--- a/src/app/shell_desktop.cpp+++ b/src/app/shell_desktop.cpp@@ -17,6 +17,7 @@#include <SDL3/SDL.h>#include <atomic>+#include <csignal>#include <cstdio>#include <cstdlib>@@ -25,6 +26,8 @@ namespace xc::app::shell {namespace {bool g_quit = false; // main threadstd::atomic<bool> g_focus{true}; // the window has the keyboard+volatile std::sig_atomic_t g_signalled = 0;+void onSignal(int) { g_signalled = 1; }} // namespacevoid beforeSettings() {@@ -36,6 +39,11 @@ void beforeDisplay(const Settings&) {// loop is ours.if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD | SDL_INIT_AUDIO | SDL_INIT_EVENTS))XC_LOGE("SDL: %s", SDL_GetError());+ // Ctrl+C and SIGTERM close the app in order. SDL turns them into a quit+ // event only when they weren't ignored (a shell's background job+ // ignores SIGINT): ours, as psbox-headless does.+ std::signal(SIGINT, onSignal);+ std::signal(SIGTERM, onSignal);}bool afterDisplay(bool haveDisplay) {@@ -81,6 +89,10 @@ bool pumpEvents() {}input::sdlInputEvent(ev);}+ if (g_signalled && !g_quit) {+ XC_LOGI("closing on a signal");+ g_quit = true;+ }return !g_quit;}