initialize fields, allow missing pidfile

This commit is contained in:
john30
2014-12-18 22:04:23 +01:00
parent cdf7fb6522
commit d078044c36
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ void Daemon::run(const char* pidfile)
close(STDERR_FILENO);
// 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;
exit(EXIT_FAILURE);
}
+4 -2
View File
@@ -20,6 +20,8 @@
#ifndef LIBUTILS_DAEMON_H_
#define LIBUTILS_DAEMON_H_
#include <cstddef>
/** \file daemon.h */
/**
@@ -44,7 +46,7 @@ public:
/**
* @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.
@@ -56,7 +58,7 @@ private:
/**
* @brief private construtor.
*/
Daemon() {}
Daemon() : m_status(false), m_pidfile(NULL), m_pidfd(0) {}
/**
* @brief private copy construtor.