mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Move signal handler code to frontend driver interface
This commit is contained in:
parent
76cc6fd8ec
commit
8d5f34eeb9
@ -13,14 +13,10 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "../../driver.h"
|
||||
#include "../../general.h"
|
||||
#include "../../runloop.h"
|
||||
#include "../../frontend/frontend_driver.h"
|
||||
#include "../common/vulkan_common.h"
|
||||
|
||||
typedef struct
|
||||
@ -31,16 +27,6 @@ typedef struct
|
||||
unsigned height;
|
||||
} khr_display_ctx_data_t;
|
||||
|
||||
#ifndef _WIN32
|
||||
static volatile sig_atomic_t g_khr_quit;
|
||||
static void khr_sighandler(int sig)
|
||||
{
|
||||
if (g_khr_quit)
|
||||
exit(1);
|
||||
g_khr_quit = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gfx_ctx_khr_display_destroy(void *data)
|
||||
{
|
||||
khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)data;
|
||||
@ -66,9 +52,6 @@ static void gfx_ctx_khr_display_get_video_size(void *data,
|
||||
|
||||
static void *gfx_ctx_khr_display_init(void *video_driver)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct sigaction sa;
|
||||
#endif
|
||||
khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)calloc(1, sizeof(*khr));
|
||||
if (!khr)
|
||||
return NULL;
|
||||
@ -79,15 +62,7 @@ static void *gfx_ctx_khr_display_init(void *video_driver)
|
||||
goto error;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/* FIXME: Consolidate all sig-handling like this outside context drivers. */
|
||||
sa.sa_sigaction = NULL;
|
||||
sa.sa_handler = khr_sighandler;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
#endif
|
||||
frontend_driver_install_signal_handler();
|
||||
|
||||
return khr;
|
||||
|
||||
@ -111,11 +86,7 @@ static void gfx_ctx_khr_display_check_window(void *data, bool *quit,
|
||||
*resize = true;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
|
||||
#else
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL) || g_khr_quit)
|
||||
#endif
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL) || (bool)frontend_driver_get_signal_handler_state())
|
||||
*quit = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user