X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FDaemon%2FDaemon.hh;h=89e2d53fe27273ae931c5102e93f0720d6ce56c5;hb=2c6294b3a810ee64e117df1b0da01d6b120534bb;hp=25b8e603fcab1aed7e0732097553c5c838bc4418;hpb=6876608d730140be160e1cd33094d493e88dee79;p=senf.git diff --git a/Utils/Daemon/Daemon.hh b/Utils/Daemon/Daemon.hh index 25b8e60..89e2d53 100644 --- a/Utils/Daemon/Daemon.hh +++ b/Utils/Daemon/Daemon.hh @@ -28,6 +28,7 @@ // Custom includes #include +#include "../Logger/SenfLog.hh" //#include "Daemon.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -103,6 +104,8 @@ namespace senf { class Daemon : boost::noncopyable { public: + SENF_LOG_CLASS_AREA(); + /////////////////////////////////////////////////////////////////////////// // Types @@ -154,9 +157,14 @@ namespace senf { successful startup. */ int argc(); ///< Access command line parameter count - char ** argv(); ///< Access command line parameters + char ** argv(); ///< Access command line parameters + void removeDaemonArgs(); ///< Remove the daemon arguments from argc()/argv() + + static void exit(unsigned code=0); ///< Terminate daemon with failure - static void exit(unsigned code=0); ///< Terminate daemon with failure + void logReopen(); ///< Reopen the log files + /**< This is used when rotating the logs. By default, + SIGHUP calls logReopen. */ ///\} @@ -164,6 +172,8 @@ namespace senf { /**< Normally not called directly but from the \ref SENF_DAEMON_MAIN macro. */ + static Daemon & instance(); ///< Return the Daemon instance + protected: Daemon(); @@ -195,10 +205,10 @@ namespace senf { This member is only called, if the default main() implementation is not overridden. */ private: - void openLog(); void fork(); bool pidfileCreate(); + void installSighandlers(); int argc_; char ** argv_; @@ -212,6 +222,8 @@ namespace senf { bool pidfileCreated_; bool detached_; + + static Daemon * instance_; }; /** \brief Provide \c main() function