internal: add a watchdog

a watchdog will abort processing a signal if a timeout specified via debug:watchdog_timeout is reached.
This commit is contained in:
vaxerski
2023-09-29 16:38:13 +01:00
parent 3f09b14381
commit 9cc614d096
6 changed files with 99 additions and 1 deletions

View File

@@ -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);