From 4b0d587fe108be85b2d3d37b45d5a53f0e51fb1a Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 8 Mar 2016 15:02:32 -0500 Subject: [PATCH] Daemon::run --- Daemon.h | 7 +++++-- DaemonLinux.cpp | 9 +++++++++ i2pd.cpp | 8 +------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Daemon.h b/Daemon.h index e755e3e9..4f31b2dc 100644 --- a/Daemon.h +++ b/Daemon.h @@ -20,6 +20,7 @@ namespace i2p virtual bool init(int argc, char* argv[]); virtual bool start(); virtual bool stop(); + virtual void run () {}; bool isLogging; bool isDaemon; @@ -61,8 +62,10 @@ namespace i2p return instance; } - virtual bool start(); - virtual bool stop(); + bool start(); + bool stop(); +; void run (); + private: std::string pidfile; int pidFH; diff --git a/DaemonLinux.cpp b/DaemonLinux.cpp index 2ccbfe38..53d9f61e 100644 --- a/DaemonLinux.cpp +++ b/DaemonLinux.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -118,6 +119,14 @@ namespace i2p return Daemon_Singleton::stop(); } + + void DaemonLinux::run () + { + while (running) + { + std::this_thread::sleep_for (std::chrono::seconds(1)); + } + } } } diff --git a/i2pd.cpp b/i2pd.cpp index 32749d16..6167f10e 100644 --- a/i2pd.cpp +++ b/i2pd.cpp @@ -1,4 +1,3 @@ -#include #include #include "Daemon.h" @@ -6,12 +5,7 @@ int main( int argc, char* argv[] ) { Daemon.init(argc, argv); if (Daemon.start()) - { - while (Daemon.running) - { - std::this_thread::sleep_for (std::chrono::seconds(1)); - } - } + Daemon.run (); Daemon.stop(); return EXIT_SUCCESS; }