From a4acd2bc276bdad46aaa033cb76403d56e5b3270 Mon Sep 17 00:00:00 2001 From: Ruud Overeem <overeem@astron.nl> Date: Mon, 31 May 2010 12:50:56 +0000 Subject: [PATCH] Bug 1000: Observation will be aborted in a nice way when the process is killed with -6 (-s SIGABRT). --- .../ObservationControl/ObservationControl.cc | 22 ++++++++++++++++++- .../ObservationControl/ObservationControl.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc index b095208b69a..a431691d834 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc @@ -155,7 +155,12 @@ void ObservationControl::sigintHandler(int signum) // Note we can't call TRAN here because the siginthandler does not know our object. if (thisObservationControl) { - thisObservationControl->finish(); + if (signum == SIGABRT) { + thisObservationControl->abortObservation(); + } + else { + thisObservationControl->finish(); + } } } @@ -167,6 +172,20 @@ void ObservationControl::finish() TRAN(ObservationControl::finishing_state); } +// +// abortObservation +// +void ObservationControl::abortObservation() +{ + LOG_WARN("Received manual interrupt to ABORT the observation"); + if (itsState < CTState::RESUME) { + itsQuitReason = CT_RESULT_MANUAL_ABORT; + } + itsTimerPort->cancelTimer(itsStopTimer); // cancel old timer + itsStopTimer = itsTimerPort->setTimer(0.0); // expire immediately + // will result in F_TIMER in ::active_state +} + // // setState(CTstateNr) // @@ -233,6 +252,7 @@ GCFEvent::TResult ObservationControl::starting_state(GCFEvent& event, thisObservationControl = this; signal (SIGINT, ObservationControl::sigintHandler); // ctrl-c signal (SIGTERM, ObservationControl::sigintHandler); // kill + signal (SIGABRT, ObservationControl::sigintHandler); // kill -6 // register what we are doing setState(CTState::CONNECT); diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h index ba24199ae85..7c768928583 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h @@ -82,6 +82,7 @@ public: // Interrupt handler for switching to finishing_state when exiting program. static void sigintHandler (int signum); void finish (); + void abortObservation (); private: // avoid defaultconstruction and copying -- GitLab