summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-09-29 16:38:13 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-09-29 16:38:13 +0100
commit9cc614d096db4b7c1de6baaa055ca6f741aa4370 (patch)
tree23e6c59fed8dea0c27669bd9a4dec6a31e54aa8b /src/Compositor.cpp
parent3f09b14381e8b28dd2cc1d292763374f2d6c8484 (diff)
internal: add a watchdog
a watchdog will abort processing a signal if a timeout specified via debug:watchdog_timeout is reached.
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp11
1 files changed, 11 insertions, 0 deletions
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<CWatchdog>();
}
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);