From 847cd9f34758cc11a54e44f318ad542d54d63755 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 19 Jun 2019 08:36:37 -0400 Subject: [PATCH] Print out an error when a monitor is in MONITOR mode because we can't handle alarms. Allow signals to terminate zmu by checking zm_terminate. --- src/zmu.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/zmu.cpp b/src/zmu.cpp index 07f9ae8aa..bd70f8337 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -571,14 +571,18 @@ int main(int argc, char *argv[]) { monitor->DumpZoneImage(zoneString); } if ( function & ZMU_ALARM ) { - if ( verbose ) - printf("Forcing alarm on\n"); - monitor->ForceAlarmOn(config.forced_alarm_score, "Forced Web"); - while ( monitor->GetState() != Monitor::ALARM ) { - // Wait for monitor to notice. - usleep(1000); - } - printf("Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId()); + if ( monitor->GetFunction() == Monitor::Function::MONITOR ) { + printf("A Monitor in monitor mode cannot handle alarms. Please use NoDect\n"); + } else { + if ( verbose ) + printf("Forcing alarm on\n"); + monitor->ForceAlarmOn(config.forced_alarm_score, "Forced Web"); + while ( (monitor->GetState() != Monitor::ALARM) && !zm_terminate ) { + // Wait for monitor to notice. + usleep(1000); + } + printf("Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId()); + } // end if ! MONITOR } if ( function & ZMU_NOALARM ) { if ( verbose )