summaryrefslogtreecommitdiff
path: root/lib/server/Daemon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/server/Daemon.cpp')
-rwxr-xr-xlib/server/Daemon.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp
index ca2df62f..a4dfdaec 100755
--- a/lib/server/Daemon.cpp
+++ b/lib/server/Daemon.cpp
@@ -11,11 +11,14 @@
#include <stdio.h>
#include <unistd.h>
-#include <syslog.h>
#include <signal.h>
#include <string.h>
#include <stdarg.h>
+#ifndef WIN32
+#include <syslog.h>
+#endif
+
#include "Daemon.h"
#include "Configuration.h"
#include "ServerException.h"
@@ -140,6 +143,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
// Let the derived class have a go at setting up stuff in the initial process
SetupInInitialProcess();
+#ifndef WIN32
// Set signal handler
struct sigaction sa;
sa.sa_handler = SignalHandler;
@@ -219,12 +223,14 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
break;
}
}
+#endif // ! WIN32
// open the log
::openlog(DaemonName(), LOG_PID, LOG_LOCAL6);
// Log the start message
::syslog(LOG_INFO, "Starting daemon (config: %s) (version " BOX_VERSION ")", configfile);
+#ifndef WIN32
// Write PID to file
char pid[32];
int pidsize = sprintf(pid, "%d", (int)getpid());
@@ -233,6 +239,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
::syslog(LOG_ERR, "can't write pid file");
THROW_EXCEPTION(ServerException, DaemoniseFailed)
}
+#endif
// Set up memory leak reporting
#ifdef BOX_MEMORY_LEAK_TESTING
@@ -245,6 +252,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
if(asDaemon)
{
+#ifndef WIN32
// Close standard streams
::close(0);
::close(1);
@@ -265,8 +273,9 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
{
::close(devnull);
}
-
- // And definately don't try and send anything to those file descriptors
+#endif // ! WIN32
+
+ // And definitely don't try and send anything to those file descriptors
// -- this has in the past sent text to something which isn't expecting it.
TRACE_TO_STDOUT(false);
}
@@ -357,6 +366,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
// --------------------------------------------------------------------------
void Daemon::EnterChild()
{
+#ifndef WIN32
// Unset signal handlers
struct sigaction sa;
sa.sa_handler = SIG_DFL;
@@ -364,6 +374,7 @@ void Daemon::EnterChild()
sigemptyset(&sa.sa_mask); // macro
::sigaction(SIGHUP, &sa, NULL);
::sigaction(SIGTERM, &sa, NULL);
+#endif
}
@@ -377,6 +388,7 @@ void Daemon::EnterChild()
// --------------------------------------------------------------------------
void Daemon::SignalHandler(int sigraised)
{
+#ifndef WIN32
if(spDaemon != 0)
{
switch(sigraised)
@@ -393,6 +405,7 @@ void Daemon::SignalHandler(int sigraised)
break;
}
}
+#endif
}
// --------------------------------------------------------------------------
@@ -534,5 +547,3 @@ void Daemon::SetProcessTitle(const char *format, ...)
#endif // HAVE_SETPROCTITLE
}
-
-