From 9cc614d096db4b7c1de6baaa055ca6f741aa4370 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:38:13 +0100 Subject: internal: add a watchdog a watchdog will abort processing a signal if a timeout specified via debug:watchdog_timeout is reached. --- src/Compositor.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 1cb378db..e114e934 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -34,6 +34,13 @@ void handleUnrecoverableSignal(int sig) { abort(); } +void handleUserSignal(int sig) { + if (sig == SIGUSR1) { + // means we have to unwind a timed out event + throw std::exception(); + } +} + CCompositor::CCompositor() { m_iHyprlandPID = getpid(); @@ -70,6 +77,8 @@ CCompositor::CCompositor() { setRandomSplash(); Debug::log(LOG, "\nCurrent splash: {}\n\n", m_szCurrentSplash); + + g_pWatchdog = std::make_unique(); } CCompositor::~CCompositor() { @@ -92,6 +101,7 @@ CCompositor::~CCompositor() { g_pAnimationManager.reset(); g_pKeybindManager.reset(); g_pHookSystem.reset(); + g_pWatchdog.reset(); } void CCompositor::setRandomSplash() { @@ -112,6 +122,7 @@ void CCompositor::initServer() { wl_event_loop_add_signal(m_sWLEventLoop, SIGTERM, handleCritSignal, nullptr); signal(SIGSEGV, handleUnrecoverableSignal); signal(SIGABRT, handleUnrecoverableSignal); + signal(SIGUSR1, handleUserSignal); //wl_event_loop_add_signal(m_sWLEventLoop, SIGINT, handleCritSignal, nullptr); initManagers(STAGE_PRIORITY); -- cgit v1.2.3