From c50be5b262a3c408fc29be9b6442d60b3eb5a0e9 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 23 May 2017 10:43:34 -0400 Subject: [PATCH] 2017-05-23 Fred Gleason * Modified ripcd(8) to allow switcher drivers to execute cleanup code at program shutdown. --- ChangeLog | 3 +++ ripcd/ripcd.cpp | 33 ++++++++++++++++++++++++--------- ripcd/ripcd.h | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 627a25f6..bd2dd02c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15801,3 +15801,6 @@ * Added an 'RDMatrix::KernelGpio' element to the 'RDMatrix::Type enum. * Implemented a Kernel GPIO switcher driver in 'ripcd/kernelgpio.cpp' and 'ripcd/kernelgpio.h'. +2017-05-23 Fred Gleason + * Modified ripcd(8) to allow switcher drivers to execute cleanup + code at program shutdown. diff --git a/ripcd/ripcd.cpp b/ripcd/ripcd.cpp index d02051c3..1392b51c 100644 --- a/ripcd/ripcd.cpp +++ b/ripcd/ripcd.cpp @@ -55,7 +55,7 @@ RDConfig *ripcd_config; RDCae *rdcae; RDStation *rdstation; - +bool global_exiting=false; void SigHandler(int signo) { @@ -73,15 +73,8 @@ void SigHandler(int signo) return; case SIGTERM: - LogLine(RDConfig::LogInfo,"ripcd exiting normally"); - RDDeletePid(RD_PID_DIR,"ripcd.pid"); - exit(0); - break; - case SIGINT: - LogLine(RDConfig::LogInfo,"ripcd exiting on SIGINT"); - RDDeletePid(RD_PID_DIR,"ripcd.pid"); - exit(0); + global_exiting=true; break; } } @@ -249,6 +242,13 @@ MainObject::MainObject(QObject *parent) log(RDConfig::LogInfo,"maintenance checks disabled on this host!"); } + // + // Exit Timer + // + timer=new QTimer(this); + connect(timer,SIGNAL(timeout()),this,SLOT(exitTimerData())); + timer->start(200); + LogLine(RDConfig::LogInfo,"started"); } @@ -408,6 +408,21 @@ void MainObject::macroTimerData(int num) } +void MainObject::exitTimerData() +{ + if(global_exiting) { + for(int i=0;isetUserName(username); diff --git a/ripcd/ripcd.h b/ripcd/ripcd.h index 066ed7b7..d6aee281 100644 --- a/ripcd/ripcd.h +++ b/ripcd/ripcd.h @@ -77,6 +77,7 @@ class MainObject : public QObject void socketData(int); void socketKill(int); void checkMaintData(); + void exitTimerData(); private: void SetUser(QString username);