Fix CTRL-C on non event loop apps

This commit is contained in:
2025-07-28 02:10:07 -05:00
parent 739da024a6
commit afdcab8cd9
2 changed files with 8 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ namespace Tesses::Framework
void TF_Init(); void TF_Init();
void TF_InitWithConsole(); void TF_InitWithConsole();
void TF_ConnectToSelf(uint16_t port); void TF_ConnectToSelf(uint16_t port);
void TF_InitEventLoop();
void TF_RunEventLoop(); void TF_RunEventLoop();
void TF_RunEventLoopItteration(); void TF_RunEventLoopItteration();
bool TF_IsRunning(); bool TF_IsRunning();

View File

@@ -94,6 +94,7 @@ namespace Tesses::Framework
} }
void TF_RunEventLoop() void TF_RunEventLoop()
{ {
TF_InitEventLoop();
while(isRunning) while(isRunning)
{ {
TF_RunEventLoopItteration(); TF_RunEventLoopItteration();
@@ -173,6 +174,11 @@ namespace Tesses::Framework
#endif #endif
} }
void TF_InitEventLoop()
{
signal(SIGINT,_sigInt);
signal(SIGTERM, _sigInt);
}
void TF_Init() void TF_Init()
{ {
@@ -221,8 +227,7 @@ if (iResult != 0) {
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller) // Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
#else #else
signal(SIGPIPE,SIG_IGN); signal(SIGPIPE,SIG_IGN);
signal(SIGINT,_sigInt);
signal(SIGTERM, _sigInt);
#endif #endif
} }