From 4bcefe05623ab349907947785bfe3473079f0d07 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 31 Jan 2021 11:44:58 -0500 Subject: [PATCH] Add a 10 second wait to force alarm on. If the monitor doesn't notice it is likely not running, leaving an mmap behind --- src/zmu.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/zmu.cpp b/src/zmu.cpp index 301619305..6fce000b3 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -586,11 +586,17 @@ int main(int argc, char *argv[]) { ); } monitor->ForceAlarmOn(config.forced_alarm_score, "Forced Web"); - while ( ((state = monitor->GetState()) != Monitor::ALARM) && !zm_terminate ) { + int wait = 10*1000*1000; // 10 seconds + while ( ((state = monitor->GetState()) != Monitor::ALARM) and !zm_terminate and wait) { // Wait for monitor to notice. usleep(1000); + wait -= 1000; + } + if ( (state = monitor->GetState()) != Monitor::ALARM and !wait ) { + Error("Monitor failed to respond to forced alarm."); + } else { + printf("Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId()); } - printf("Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId()); } } // end if ZMU_ALARM