initialize fields, allow missing pidfile
This commit is contained in:
@@ -81,7 +81,7 @@ void Daemon::run(const char* pidfile)
|
|||||||
close(STDERR_FILENO);
|
close(STDERR_FILENO);
|
||||||
|
|
||||||
// write pidfile and try to lock it
|
// write pidfile and try to lock it
|
||||||
if (pidfile_open() == false) {
|
if (m_pidfile != NULL && pidfile_open() == false) {
|
||||||
cerr << "can't open pidfile: %s" << m_pidfile << endl;
|
cerr << "can't open pidfile: %s" << m_pidfile << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#ifndef LIBUTILS_DAEMON_H_
|
#ifndef LIBUTILS_DAEMON_H_
|
||||||
#define LIBUTILS_DAEMON_H_
|
#define LIBUTILS_DAEMON_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
/** \file daemon.h */
|
/** \file daemon.h */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +46,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief stop daemon and delete the pid file.
|
* @brief stop daemon and delete the pid file.
|
||||||
*/
|
*/
|
||||||
void stop() { pidfile_close(); }
|
void stop() { if (m_pidfile != NULL) pidfile_close(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief show actual status if daemonize.
|
* @brief show actual status if daemonize.
|
||||||
@@ -56,7 +58,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief private construtor.
|
* @brief private construtor.
|
||||||
*/
|
*/
|
||||||
Daemon() {}
|
Daemon() : m_status(false), m_pidfile(NULL), m_pidfd(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief private copy construtor.
|
* @brief private copy construtor.
|
||||||
|
|||||||
Reference in New Issue
Block a user