From e674014efc82acf8a12bbec9ae1c6a66d4772cc3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Apr 2014 06:15:07 +0200 Subject: [PATCH] fix Linux Daemon --- Daemon.h | 6 +++++- DaemonLinux.cpp | 14 +++++++++----- Makefile | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Daemon.h b/Daemon.h index d7fdc82a..86971d29 100644 --- a/Daemon.h +++ b/Daemon.h @@ -57,7 +57,11 @@ namespace i2p virtual bool start(); virtual bool stop(); + private: + std::string pidfile; + int pidFilehandle; + }; #endif } -} \ No newline at end of file +} diff --git a/DaemonLinux.cpp b/DaemonLinux.cpp index 116e0ae6..4cfd51ce 100644 --- a/DaemonLinux.cpp +++ b/DaemonLinux.cpp @@ -6,6 +6,10 @@ #include #include +//#include +#include "util.h" + + void handle_signal(int sig) { switch (sig) @@ -26,7 +30,7 @@ void handle_signal(int sig) case SIGABRT: case SIGTERM: case SIGINT: - running = 0; // Exit loop + Daemon.running = 0; // Exit loop break; } } @@ -63,9 +67,9 @@ namespace i2p } // Pidfile - std::string pidfile = i2p::util::filesystem::GetDataDir().string(); + pidfile = i2p::util::filesystem::GetDataDir().string(); pidfile.append("/i2pd.pid"); - int pidFilehandle = open(pidfile.c_str(), O_RDWR | O_CREAT, 0600); + pidFilehandle = open(pidfile.c_str(), O_RDWR | O_CREAT, 0600); if (pidFilehandle == -1) { LogPrint("Error, could not create pid file (", pidfile, ")\nIs an instance already running?"); @@ -90,7 +94,7 @@ namespace i2p sigaction(SIGTERM, &sa, 0); sigaction(SIGINT, &sa, 0); - retunrn Daemon_Singleton::start(); + return Daemon_Singleton::start(); } bool DaemonLinux::stop() @@ -106,4 +110,4 @@ namespace i2p } } -#endif \ No newline at end of file +#endif diff --git a/Makefile b/Makefile index fec4f79d..2d30a01c 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ OBJECTS = obj/i2p.o obj/base64.o obj/NTCPSession.o obj/RouterInfo.o obj/Transpor obj/RouterContext.o obj/NetDb.o obj/LeaseSet.o obj/Tunnel.o obj/TunnelEndpoint.o \ obj/TunnelGateway.o obj/TransitTunnel.o obj/I2NPProtocol.o obj/Log.o obj/Garlic.o \ obj/HTTPServer.o obj/Streaming.o obj/Identity.o obj/SSU.o obj/util.o obj/Reseed.o \ - obj/UPnP.o obj/TunnelPool.o obj/HTTPProxy.o obj/AddressBook.o + obj/UPnP.o obj/TunnelPool.o obj/HTTPProxy.o obj/AddressBook.o \ + obj/Daemon.o obj/DaemonLinux.o INCFLAGS = LDFLAGS = -Wl,-rpath,/usr/local/lib -lcryptopp -lboost_system -lboost_filesystem -lboost_regex -lboost_program_options -lpthread LIBS =