From 941c651fadb926f0aeafe3ed5dc02b87eb91d635 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sun, 24 Jan 2021 17:10:52 -0500 Subject: [PATCH] [client] unconditionally quit on second SIGINT Under some circumstances, Looking Glass can hang when SIGINT'd, for instance, if it's stuck waiting on spice I/O that won't complete because the guest is misbehaving. This commit provides an escape hatch for such cases, so one doesn't have to reach for `kill -9 $(pidof looking-glass-client)`. --- client/src/main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 76735a92..8a419178 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1609,14 +1609,23 @@ int eventFilter(void * userdata, SDL_Event * event) return 0; } -void int_handler(int signal) +void int_handler(int sig) { - switch(signal) + switch(sig) { case SIGINT: case SIGTERM: - DEBUG_INFO("Caught signal, shutting down..."); - g_state.state = APP_STATE_SHUTDOWN; + if (g_state.state != APP_STATE_SHUTDOWN) + { + DEBUG_INFO("Caught signal, shutting down..."); + g_state.state = APP_STATE_SHUTDOWN; + } + else + { + DEBUG_INFO("Caught second signal, force quitting..."); + signal(sig, SIG_DFL); + raise(sig); + } break; } }