mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 14:31:17 +12:00
Add SIGINT handler on posix systems (#145)
This commit is contained in:
parent
b1844a8753
commit
a3b1af4e3d
4 changed files with 38 additions and 43 deletions
36
src/Common/ExceptionHandler/ExceptionHandler_posix.cpp
Normal file
36
src/Common/ExceptionHandler/ExceptionHandler_posix.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
|
||||
void handler_SIGSEGV(int sig)
|
||||
{
|
||||
printf("SIGSEGV!\n");
|
||||
|
||||
void *array[32];
|
||||
size_t size;
|
||||
|
||||
// get void*'s for all entries on the stack
|
||||
size = backtrace(array, 32);
|
||||
|
||||
// print out all the frames to stderr
|
||||
fprintf(stderr, "Error: signal %d:\n", sig);
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void handler_SIGINT(int sig)
|
||||
{
|
||||
/*
|
||||
* Received when pressing CTRL + C in a console
|
||||
* Ideally should be exiting cleanly after saving settings but currently
|
||||
* there's no clean exit pathway (at least on linux) and exiting the app
|
||||
* by any mean ends up with a SIGABRT from the standard library destroying
|
||||
* threads.
|
||||
*/
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void ExceptionHandler_init()
|
||||
{
|
||||
signal(SIGSEGV, handler_SIGSEGV);
|
||||
signal(SIGINT, handler_SIGINT);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue