documentation for class Daemon added.

This commit is contained in:
Roland Jax
2014-11-16 14:25:23 +01:00
parent e4e709ec6a
commit ada6a066fe
3 changed files with 42 additions and 10 deletions
+2 -2
View File
@@ -32,10 +32,10 @@ Daemon& Daemon::Instance()
return instance;
}
void Daemon::run(const char* file)
void Daemon::run(const char* pidfile)
{
m_status = false;
m_pidfile = file;
m_pidfile = pidfile;
m_pidfd = 0;
pid_t pid;
+39 -7
View File
@@ -20,27 +20,59 @@
#ifndef LIBUTILS_DAEMON_H_
#define LIBUTILS_DAEMON_H_
/**
* @brief class to daemonize a process.
*/
class Daemon
{
public:
/**
* @brief create an daemon instance and return the reference.
* @return the reference to instance.
*/
static Daemon& Instance();
~Daemon() {}
void run(const char* file);
/**
* @brief daemonize act process.
* @param pidfile the name of the pid file.
*/
void run(const char* pidfile);
/**
* @brief stop daemon and delete the pid file.
*/
void stop() { pidfile_close(); }
/**
* @brief show actual status if daemonize.
* @return true if process is a daemon.
*/
bool status() { return m_status; }
private:
bool m_status;
const char* m_pidfile;
int m_pidfd;
/** private constructor - singleton pattern */
Daemon() {}
Daemon(const Daemon&);
Daemon& operator= (const Daemon&);
Daemon& operator=(const Daemon&);
/** status of process; true if we are a daemon */
bool m_status;
/** name of the pid file*/
const char* m_pidfile;
/** file descriptor of the pid file */
int m_pidfd;
/**
* @brief creates a pid file for process.
* @return true if success.
*/
bool pidfile_open();
/**
* @brief close and delete the pid file.
* @return true if success.
*/
bool pidfile_close();
};
+1 -1
View File
@@ -155,7 +155,7 @@ public:
private:
LogInstance() {}
LogInstance(const LogInstance&);
LogInstance& operator= (const LogInstance&);
LogInstance& operator=(const LogInstance&);
typedef std::vector<LogSink*> sink_t;
typedef std::vector<LogSink*>::iterator sinkCI_t;